Answer the question
In order to leave comments, you need to log in
How to properly add front to spring boot rest api?
Developed an API. Requests for specific resources:
/api/auth/register
/api/auth/verify
/api/auth/login
/api/users
/api/users/{id}/shelves
/api/shelves/{id}/books
/api/books/{id}/wish
и т.д.
@Controller
public class IndexController {
@GetMapping("/")
public String index() {
return "index";
}
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().and().cors().and().csrf().disable()
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests().antMatchers("/api/auth/*").permitAll()
.antMatchers("/", "/resources/**").permitAll()
.anyRequest().authenticated();
http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);
}
Answer the question
In order to leave comments, you need to log in
static should be sent directly, not go through the backend, and even more so through
the
firewall static-resources
As an option: leave the server with API behind the spring, and give the server with statics (including the front-end index.html) to another server with Nginx, or do as I advised above ... faster and more convenient, probably like this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question