revised CORS config for lalowed origins
This commit is contained in:
@@ -8,16 +8,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class CorsConfig implements WebMvcConfigurer {
|
public class CorsConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
@Value("${vaessl.frontend-local-url}")
|
@Value("${vaessl.allowed-origins}")
|
||||||
private String frontendLocalUrl;
|
private String[] allowedOrigins;
|
||||||
|
|
||||||
@Value("${vaessl.frontend-public-url}")
|
|
||||||
private String frontendPublicUrl;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
registry.addMapping("/**")
|
registry.addMapping("/**")
|
||||||
.allowedOrigins(frontendLocalUrl, frontendPublicUrl)
|
.allowedOrigins(allowedOrigins)
|
||||||
.allowedMethods("GET", "POST", "DELETE", "OPTIONS")
|
.allowedMethods("GET", "POST", "DELETE", "OPTIONS")
|
||||||
.allowedHeaders("Content-Type", "Accept")
|
.allowedHeaders("Content-Type", "Accept")
|
||||||
.allowCredentials(true);
|
.allowCredentials(true);
|
||||||
|
|||||||
@@ -5,13 +5,8 @@
|
|||||||
"description": "A description for 'spring.session.store-type'"
|
"description": "A description for 'spring.session.store-type'"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "vaessl.frontend-local-url",
|
"name": "vaessl.allowed-origins",
|
||||||
"type": "java.lang.String",
|
"type": "java.lang.String",
|
||||||
"description": "A description for 'vaessl.frontend-local-url'"
|
"description": "Comma-separated list of allowed CORS origins"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "vaessl.frontend-public-url",
|
|
||||||
"type": "java.lang.String",
|
|
||||||
"description": "A description for 'vaessl.frontend-public-url'"
|
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
@@ -30,5 +30,4 @@ server:
|
|||||||
servlet:
|
servlet:
|
||||||
context-path: /api
|
context-path: /api
|
||||||
vaessl:
|
vaessl:
|
||||||
frontend-local-url: ${FRONTEND_LOCAL_URL}
|
allowed-origins: ${ALLOWED_ORIGINS}
|
||||||
frontend-public-url: ${FRONTEND_PUBLIC_URL}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user