feat: 跨域允许配置多条IP
This commit is contained in:
parent
086c5f3f31
commit
99281f8166
@ -7,6 +7,7 @@ import org.springframework.web.cors.CorsConfiguration;
|
|||||||
import org.springframework.web.cors.CorsConfigurationSource;
|
import org.springframework.web.cors.CorsConfigurationSource;
|
||||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ -18,7 +19,7 @@ public class CorsConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
public CorsConfigurationSource corsConfigurationSource() {
|
public CorsConfigurationSource corsConfigurationSource() {
|
||||||
CorsConfiguration config = new CorsConfiguration();
|
CorsConfiguration config = new CorsConfiguration();
|
||||||
config.setAllowedOriginPatterns(List.of(allowedOrigins));
|
config.setAllowedOriginPatterns(Arrays.asList(allowedOrigins.split(",")));
|
||||||
config.setAllowCredentials(true);
|
config.setAllowCredentials(true);
|
||||||
config.addAllowedHeader("*");
|
config.addAllowedHeader("*");
|
||||||
config.addAllowedMethod("*");
|
config.addAllowedMethod("*");
|
||||||
|
@ -16,7 +16,7 @@ jwt:
|
|||||||
secret: your-secret
|
secret: your-secret
|
||||||
equip-reserve:
|
equip-reserve:
|
||||||
device-days: 7
|
device-days: 7
|
||||||
allowed-origins: http://localhost:5173
|
allowed-origins: "http://localhost:5173,http://127.0.0.1:5173"
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
mapper-locations: classpath:mapper/*.xml
|
mapper-locations: classpath:mapper/*.xml
|
||||||
configuration:
|
configuration:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user