Updated CORS to use a property
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.mattrixwv.cipherstream.config;
|
package com.mattrixwv.cipherstream.config;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
@@ -11,9 +12,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||||||
@Component
|
@Component
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
public class WebConfig implements WebMvcConfigurer{
|
public class WebConfig implements WebMvcConfigurer{
|
||||||
|
@Value("${allowedOrigins}")
|
||||||
|
private String allowedOrigins;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCorsMappings(@NonNull CorsRegistry registry){
|
public void addCorsMappings(@NonNull CorsRegistry registry){
|
||||||
registry.addMapping("/**")
|
registry.addMapping("/**")
|
||||||
.allowedOriginPatterns("http://localhost:3000");
|
.allowedOriginPatterns(allowedOrigins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"groups":[
|
||||||
|
],
|
||||||
|
"properties":[
|
||||||
|
{
|
||||||
|
"name": "allowed-origins",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"description": "Allowed CORS origins",
|
||||||
|
"defaultValue": "http://localhost:3000"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hints":[
|
||||||
|
{
|
||||||
|
"name": "allowed-origins",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"value": "http://localhost:3000",
|
||||||
|
"description": "Local development"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "https://api.cipherstream.mattrixwv.com",
|
||||||
|
"description": "Production"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1 +1,2 @@
|
|||||||
server.port=8001
|
server.port=8001
|
||||||
|
allowedOrigins=http://localhost:3000
|
||||||
|
|||||||
Reference in New Issue
Block a user