How to Fix CORS Error in SpringBoot and React

  Рет қаралды 22,274

Study Automation Academy

Study Automation Academy

Күн бұрын

Thanks for watching the video:
Subscribe Channel: / studyautomation1
My Gadgets:
MIC:- amzn.to/3UQPlaF
Camera:- amzn.to/3WYszQ3
Laptop:- amzn.to/3EsPzzt Hi Everyone, in this video, I am going to Fix one of the major errors while working with SpringBoot Project.
We will see how to fix CORS Error in Springboot and React JS.
You can create spring boot project using: start.spring.io/
Here is my code, add this code in Main Class of Springboot project:
@Bean
public WebMvcConfigurer configure() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry reg) {
reg.addMapping("/**").allowedOrigins("*");
}
};
}
Hope it will fix your problem too.

Пікірлер: 50
@nathaniellane02
@nathaniellane02 5 ай бұрын
2 years later youre still helping people out bro, thank you!
@allessioyassine3515
@allessioyassine3515 5 ай бұрын
it didn't work for me :/
@nathaniellane02
@nathaniellane02 5 ай бұрын
@allessioyassine3515 hope you find a solution soon man...I know how frustrating it can be🙏🏻
@StudyAutomationAcademy
@StudyAutomationAcademy 5 ай бұрын
Happy to help!
@arbibenmaatoug5566
@arbibenmaatoug5566 2 жыл бұрын
thank you so much , i struggled a lot between thousand of video and pdf and i confirm you are the simpliest and the most realistic ; well done and bless you;
@avantikatiwari1362
@avantikatiwari1362 2 жыл бұрын
same here
@StudyAutomationAcademy
@StudyAutomationAcademy Жыл бұрын
Thanks
@arausruben
@arausruben 2 жыл бұрын
min. 17:05 bless you!
@rony_nr
@rony_nr Жыл бұрын
🤣🤣
@madhulisuvarnakar3837
@madhulisuvarnakar3837 Жыл бұрын
You are the life saver, simple solution made my application work...Thank you soo much!
@StudyAutomationAcademy
@StudyAutomationAcademy Жыл бұрын
Thanks Buddy..
@Psychopatz
@Psychopatz 9 ай бұрын
OMGGGGG YOU HAVE NO IDEA HOW FRUSTRATING TO SEE THIS ERROR DUDE, SUPPERRR THANKSS KIND SAMARITAN
@StudyAutomationAcademy
@StudyAutomationAcademy 9 ай бұрын
Glad it helped!
@nagararun
@nagararun 11 ай бұрын
thanks bro i struggled a lot in between many times once again thanks 👍👍👍
@user-wr8gc8vo6m
@user-wr8gc8vo6m Жыл бұрын
Wonderful explanation bro, keep it up.👍
@JohnDoe-ej6vm
@JohnDoe-ej6vm 2 жыл бұрын
i used this annotation but still getting same error in react .
@alfonsopayra
@alfonsopayra 2 жыл бұрын
same here... i am getting insane with this shit
@PrevalentAA
@PrevalentAA 2 жыл бұрын
@@alfonsopayra solved it by any chance?
@MRPRK365
@MRPRK365 2 жыл бұрын
@@PrevalentAA same error i'm facing
@PrevalentAA
@PrevalentAA 2 жыл бұрын
@@MRPRK365 it eventually worked for me. The annotation that is. Also make sure in your security config that you allow that request to be made to your server
@gui3623
@gui3623 4 ай бұрын
17:07 bless you
@sharathlingam3444
@sharathlingam3444 Жыл бұрын
This worked so well bro, thanks a lot.
@StudyAutomationAcademy
@StudyAutomationAcademy Жыл бұрын
Thanks
@MrRider-kw8mq
@MrRider-kw8mq Жыл бұрын
Thank you my friend . I really need this solution
@naveenkumarvtamil
@naveenkumarvtamil Ай бұрын
Thank you so much ❤😊
@alfonsopayra
@alfonsopayra 2 жыл бұрын
none of this works for me
@fq08sujalbirari82
@fq08sujalbirari82 4 ай бұрын
Hey, I am also having the same error, none of the Cross-Origin annots or extra configs are working for me. Have you solved your problem yet, if so then plz tell me how
@oumaimalaamrani9404
@oumaimalaamrani9404 3 ай бұрын
@@fq08sujalbirari82 have you solved it?
@farzanfarooqui4526
@farzanfarooqui4526 9 ай бұрын
Thank you so much it was really helpful ❤
@LamHoangQuan88
@LamHoangQuan88 2 ай бұрын
thank you soo much 💯
@binhcoding3am148
@binhcoding3am148 Жыл бұрын
thankui bro, this is what i need
@bharanitharan1220
@bharanitharan1220 5 ай бұрын
Thanks alot bro ❤
@bhanusingh7309
@bhanusingh7309 Жыл бұрын
one more person helped!..thanks
@StudyAutomationAcademy
@StudyAutomationAcademy Жыл бұрын
Thanks
@GeorgeDumitra
@GeorgeDumitra 9 ай бұрын
But this is not a fix! this is a security issue as you basically have disabled all the CORS protection based on the origin! Very dangerous to put this in production!
@AnkitTiwari-qt5ds
@AnkitTiwari-qt5ds 7 ай бұрын
I am facing the same security issue.. can you please guide me how to fix it??
@GeorgeDumitra
@GeorgeDumitra 7 ай бұрын
@@AnkitTiwari-qt5ds you need to define for each method the respective CROS rights @GetMapping(path = "test") @CrossOrigin(origins = { "localhost:8080" }) public String test(){...} this means that if you call the localhost:8081/test from your React app running on localhost:8080 then you will have no issues as the only way to call the "/test" is that the caller is an application running on 8080. In this example my SPRING server that serves the "/test" is running on 8081. All works perfect and safe. If I have another app running on 9090 and calling the SPRING on my server on localhost:8081/test then it will fail.
@asadkhandadlo6572
@asadkhandadlo6572 2 жыл бұрын
Thanks so much for the video, but please address pitfalls of this approach in production too, because it is not valid solution to allow all requests by just putting "*" 🙄
@StudyAutomationAcademy
@StudyAutomationAcademy 2 жыл бұрын
Nice observation
@princeberi4501
@princeberi4501 Жыл бұрын
Thank you sir 👍
@StudyAutomationAcademy
@StudyAutomationAcademy Жыл бұрын
Most welcome
@kristiansdanilovs1518
@kristiansdanilovs1518 4 ай бұрын
Doesnt work for me, but im black so it might have to do with that😊
@avantikatiwari1362
@avantikatiwari1362 2 жыл бұрын
Thank you brother!
@StudyAutomationAcademy
@StudyAutomationAcademy 2 жыл бұрын
Welcome
@charzard95738
@charzard95738 2 жыл бұрын
Thank you!
@prathameshmutkure9694
@prathameshmutkure9694 Жыл бұрын
Thanks
@atifworld
@atifworld Жыл бұрын
Thanks sir
@ashanagur3761
@ashanagur3761 Жыл бұрын
Hii for get
@alfonsopayra
@alfonsopayra 2 жыл бұрын
and it's not shlas... it is SLASHHH
@lorenllbj88
@lorenllbj88 Жыл бұрын
this does NOT work for me.
React Proxy | Easiest Fix to CORS Errors
15:52
Sam Meech-Ward
Рет қаралды 87 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 474 М.
So Cute 🥰
00:17
dednahype
Рет қаралды 45 МЛН
Throwing Swords From My Blue Cybertruck
00:32
Mini Katana
Рет қаралды 11 МЛН
У ГОРДЕЯ ПОЖАР в ОФИСЕ!
01:01
Дима Гордей
Рет қаралды 6 МЛН
Solution of the Cors Error From a Spring Boot and Angular Application
12:05
The Dev World - by Sergio Lema
Рет қаралды 16 М.
Learn CORS In 6 Minutes
6:06
Web Dev Simplified
Рет қаралды 720 М.
Best frontend and backend projects for resume
13:11
Hitesh Choudhary
Рет қаралды 209 М.
5 JavaScript Concepts You HAVE TO KNOW
9:38
James Q Quick
Рет қаралды 1,4 МЛН
How to Solve CORS error in a React app
39:07
Coders Campus
Рет қаралды 22 М.
Hosting Springboot App on render.com
20:19
bobbyctchan
Рет қаралды 30 М.
Why I Stopped Using Backend Frameworks
6:26
Ben Davis
Рет қаралды 10 М.
So Cute 🥰
00:17
dednahype
Рет қаралды 45 МЛН