[Episode 40] Enabling CORS in Spring Boot

Опубликовано: 26 Октябрь 2024
на канале: Bingyang Wei
7,423
209

Have you seen this error on the front end?

"Access to fetch at 'http://localhost:8080/api/v1/users/login' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."

The above error is due to something called a "Cross-Origin Request." In this video, I solved this problem by enabling Cross-Origin Resource Sharing (CORS) in our Spring Boot 3 application. The code is available at https://github.com/Washingtonwei/hogw...

Keep watching. Here are more Spring Security videos:
34 Introduction to Spring Security 🔗    • [Episode 34] Introduction to Spring S...  
35 Implementing HTTP Basic Authentication in Spring Boot 🔗    • [Episode 35] Implementing HTTP Basic ...  
36 Introduction to JWT 🔗    • [Episode 36] Introduction to JWT  
37 Generating JWTs in Spring Boot 🔗    • [Episode 37] Generating JWTs in Sprin...  
38 Handling Spring Security Exceptions Using @ControllerAdvice🔗    • [Episode 38] Handling Spring Security...  
39 Testing with Spring Security 🔗    • [Episode 39] Testing with Spring Secu...  
40 Enabling CORS in Spring Boot 🔗    • [Episode 40] Enabling CORS in Spring ...  
41 Committing and Pushing to a GitHub Repo 🔗    • [Episode 41] Committing and Pushing t...  

This video belongs to a playlist "Learn Spring Boot 3 with Bingyang":    • Learn Spring Boot 3 with Bingyang  

I don't want to make a super long video so I split it into smaller ones. If you want to learn Spring Boot 3 systematically, please visit the playlist (and save the playlist) for more Spring Boot 3 tutorials.

Feel free to leave a comment if you have any questions.

As always, thanks for watching, and happy learning!