ontology-driven-api
ontology-driven-api copied to clipboard
cors allow origin * headers is not set
set Access-Control-Allow-Origin: *
header for api calls
Hi, I managed to set CORS by adding the following code to src/main/java/dbpedia/api/Start.java:
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
And right below the main() function:
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins(
"http://localhost:3000"
);
}
};
}
Hi @francoguilherme could you create a PR then also the credits go to you and it is more transparent.