I’m getting the CORS issue and it’s because the CORS mapping is missing from the backend. Before adding it to the backend I tried using the chrome extension. It works for some of the APIs but when I’m
trying to access admin APIs it throws a different error.
CORS extension enabled:
Then I tried adding the CORS mapping to the backend and still no luck. I can’t continue with the emailing function because of this issue.
package org.sefglobal.scholarx.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
// Todo: Remove this configuration after congiguration of API gateway
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000")
.allowedMethods("PUT", "DELETE", "GET", "POST")
.allowCredentials(true)
.maxAge(3600);
}
}