0
I have a Spring Boot API and a Vue application, both running locally, but I can’t make a PUT request from the Vue application for API. If you send a GET request, it works perfectly. I tried, including creating a proxy as shown aui: Request with Axios and React blocked by CORS policy. But to no avail.
The error I get in the browser is as follows:
I’ve already enabled the annotation in my Source API and disabled Cors in the security configuration as well: Resource:
@RestController
@CrossOrigin
@RequestMapping(value = "/curso")
public class CursoResource {
@Autowired
CursoService cursoService;
@PutMapping(value = "/{id}")
public ResponseEntity<Void> update(@PathVariable Long id, @RequestBody Curso curso){
curso.setId(id);
cursoService.updateCurso(curso);
return ResponseEntity.noContent().build();
}
Security config:
@Override
protected void configure(HttpSecurity http) throws Exception{
http.cors().and().csrf().disable();
http.authorizeRequests()
.anyRequest().permitAll();
//.antMatchers(HttpMethod.GET, PUBLIC_MATCHERS_GET).permitAll()
//.antMatchers(HttpMethod.POST, ADMIN_MATCHERS_POST).hasAuthority("ADMIN");
//.anyRequest().authenticated();
http.addFilter(new JWTAuthenticationFilter(authenticationManager(), jwtUtil));
http.addFilter(new JWTAuthorizationFilter(authenticationManager(), jwtUtil, userDetailsService));
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
I try to make the requisition with Axios:
axios.put('http://localhost:8082/curso/' + this.cursoid, this.curso).
then((response) => {
alert('Disciplina adicionada!')
})