feat: migrate java control plane foundation
This commit is contained in:
1 parent
1615401185
commit
9da175c040
24 files changed
+1555
-12
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package com.moyi.controlplane.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
private final String[] allowedOrigins;
|
||||
|
||||
public WebConfig(@Value("${moyi.web.cors-origins}") String allowedOrigins) {
|
||||
this.allowedOrigins = Arrays.stream(allowedOrigins.split(","))
|
||||
.map(String::trim)
|
||||
.filter(origin -> !origin.isBlank())
|
||||
.toArray(String[]::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins(allowedOrigins)
|
||||
.allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
|
||||
.allowedHeaders("Content-Type", "Authorization")
|
||||
.allowCredentials(true)
|
||||
.maxAge(3600);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user