[fix] 修改了跨域认证

This commit is contained in:
LYC 2025-04-29 21:15:17 +08:00
parent 4923396996
commit cb28d1ae63
1 changed files with 3 additions and 1 deletions

View File

@ -58,7 +58,9 @@ public class SecurityConfig {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration(); CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true); config.setAllowCredentials(true);
config.setAllowedOrigins(Arrays.asList("http://localhost:9527", "http://localhost:8080","http://154.219.110.17:8080", "https://test.tju.edu.kg")); config.setAllowedOrigins(Arrays.asList("http://localhost:9527", "http://localhost:8080","http://154.219.110.17:8080", "https://test.tju.edu.kg","http://154.219.110.17:8081",
"https://project-frontend.tju.edu.kg","https://project-backend.tju.edu.kg",
"http://project-frontend.tju.edu.kg","http://project-backend.tju.edu.kg"));
config.setAllowedHeaders(Arrays.asList("*")); config.setAllowedHeaders(Arrays.asList("*"));
config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS")); config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
source.registerCorsConfiguration("/**", config); source.registerCorsConfiguration("/**", config);