yeg
2026-09-11 49fa64833f2eb3942eff55b7410932e70e4fc54e
跨域配置更新
2个文件已修改
14 ■■■■■ 已修改文件
talent-card-server/src/main/resources/application.yml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
talent-card-server/src/test/java/com/talentcard/server/config/ApiCorsConfigTests.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
talent-card-server/src/main/resources/application.yml
@@ -39,7 +39,7 @@
app:
  cors:
    # HBuilderX Web development origins; override with exact deployed frontend origins.
    allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:7893,http://localhost:7894,http://127.0.0.1:7893,http://127.0.0.1:7894}
    allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:7893,http://localhost:7894,http://127.0.0.1:7893,http://127.0.0.1:7894,http://192.168.110.26:5173}
  privacy:
    # Production must provide APP_PRIVACY_ENCRYPTION_KEY through the deployment secret store.
    encryption-key: ${APP_PRIVACY_ENCRYPTION_KEY:talent-card-local-development-key}
talent-card-server/src/test/java/com/talentcard/server/config/ApiCorsConfigTests.java
@@ -24,7 +24,7 @@
@SpringJUnitConfig({ApiCorsConfig.class, ApiCorsConfigTests.TestMvcConfig.class})
@WebAppConfiguration
@TestPropertySource(properties = "app.cors.allowed-origins=http://localhost:7894,http://127.0.0.1:7893")
@TestPropertySource(properties = "app.cors.allowed-origins=http://localhost:7894,http://127.0.0.1:7893,http://192.168.110.26:5173")
class ApiCorsConfigTests {
    @Autowired
    private WebApplicationContext context;
@@ -77,6 +77,16 @@
                .andExpect(status().isUnauthorized());
    }
    @Test
    void lanAdminFrontendCanPreflightLogin() throws Exception {
        mvc.perform(options("/api/admin/auth/login")
                        .header("Origin", "http://192.168.110.26:5173")
                        .header("Access-Control-Request-Method", "POST")
                        .header("Access-Control-Request-Headers", "content-type,x-request-id"))
                .andExpect(status().isOk())
                .andExpect(header().string("Access-Control-Allow-Origin", "http://192.168.110.26:5173"));
    }
    @Configuration
    @EnableWebMvc
    static class TestMvcConfig {