Error using Angular Delete method

Asked

Viewed 53 times

0

I have an application in Angular4 + Spring boot with the following error when I try to execute the method delete

Cross-Origin Request Blocked

The same rule of origin prevents me from reading the following link http://localhost:8080/api/user3.

(Reason: CORS header 'Access-Control-Allow-Origin' is missing).

  • Hello, this is the Stackoverflow website in Portuguese, translate your question or ask it directly on the Stackoverflow website in English

1 answer

0

In your code Spring boot, you must create a class that extends the class WebSecurityConfigurerAdapter and implement the method configure(HttpSecurity http), calling the function call

http.cors().and().csrf().disable()

Your code then should look like this:

@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.cors()
            .and()
            .csrf()
            .disable()
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.