更改allowCredentials设置。allowedOrigins允许所有设备发送请求

This commit is contained in:
2025-05-14 12:55:23 +09:00
parent 6a579104ba
commit b6bcc69a83

View File

@ -10,9 +10,8 @@ public class CorsConfig implements WebMvcConfigurer {
@Override @Override
public void addCorsMappings(CorsRegistry registry) { public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/api/**") // 允许 /api/ 下的所有请求 registry.addMapping("/api/**") // 允许 /api/ 下的所有请求
.allowedOrigins("http://192.168.1.50:5173") // 允许来自该域的请求 .allowedOrigins("*") // 允许来自该域的请求
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 允许的 HTTP 方法 .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 允许的 HTTP 方法
.allowedHeaders("*") // 允许所有头部 .allowedHeaders("*"); // 允许所有头部
.allowCredentials(true); // 允许发送 Cookie
} }
} }