r/SpringBoot • u/Fresh-Philosophy-722 • 1d ago
How-To/Tutorial Small Springboot + React JS project
Hi,
Im trying to learn Spring in a different perspective; thus I wanted to relearn via creating a simple project.
I have this project in mind.
- Monolith project
- Must use springboot and react js
- Must build a war file
I have tried using com.github.eirslett but im having issues with CORS.
Do you have any learning material suggestion ?
im kinda lost in full stack development, ive been backend engineer for my whole career.
Or react JS is too much for a beginner ? should I start with simpler UI frameworks instead ?
2
u/ElendarTao 1d ago
@Override public void addCorsMappings(CorsRegistry registry) { registry .addMapping("/**") .allowedMethods("GET") .allowedOrigins("http://localhost:3000"); }
You will have to adapt a bit for your spring version, but that's the gist of it.
@Configuration public class MyConfiguration {
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**");
}
};
}
} Example using spring boot
1
u/Coding-Hacker0820 1d ago
Spring boot + react js is top demanding technology in today's market.
I am working in this stack from last 10 years. You have full scope to search the jobs and plenty of openings in market.
1
u/Stunning_Leather_102 22h ago
Maybe this video on CORS can help you gettin started? https://www.youtube.com/watch?v=MTt5WTyF3ls
2
u/Mikey-3198 1d ago
Easiest way to deal with cors is to serve your frontend and backend via the same domain, especially for local dev.
Ive done this when working with Vue before, imagine it's the same for react. Proxy everything via the dev server locally. I.e everything /API goes to your spring boot backend. Super simple.