Skip to content
Snippets Groups Projects
Commit b1042778 authored by GAYDAMAKHA MIKHAIL's avatar GAYDAMAKHA MIKHAIL
Browse files

:bug: add cors header in response

parent 3851e471
Branches
1 merge request!32:bug: add cors header in response
......@@ -7,6 +7,7 @@ package fr.unistra.sil.erp.back;
import fr.unistra.sil.erp.back.interceptor.api.ApiAuthenticationInterceptor;
import org.springframework.context.annotation.*;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
......@@ -51,25 +52,25 @@ public class WebMvcConfig implements WebMvcConfigurer {
*/
public static final String MAPPING_ITEMS = API_FULL_PREFIX +
"/item";
/**
* API Mapping for retrieving all categories.
*/
public static final String MAPPING_CATEGORY = API_FULL_PREFIX +
"/category";
/**
* API Mapping for submitting transactions.
*/
public static final String MAPPING_SUBTRANSAC = API_FULL_PREFIX +
"/transaction";
/**
* API Mapping for retrieving stocks.
*/
public static final String MAPPING_STOCKS = API_FULL_PREFIX +
"/stock";
/**
* Web mapping for the login page.
*/
......@@ -103,6 +104,13 @@ public class WebMvcConfig implements WebMvcConfigurer {
registry.addInterceptor(new ApiAuthenticationInterceptor(this.env.getRequiredProperty("api.key"))).addPathPatterns(API_PREFIX + "**");
}
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedHeaders("*");
}
/**
* SQL Connection object.
*/
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment