feat(llmx-core-service): 添加CORS配置类
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 2m22s
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 2m22s
- 新增CorsConfig类,实现全局CORS配置 - 允许所有来源、所有HTTP方法和所有请求头- 禁用Cookie携带,预检请求缓存时间为3600秒
This commit is contained in:
parent
67a6c32c6c
commit
e6149ecb02
@ -0,0 +1,23 @@
|
|||||||
|
package org.jcnc.llmx.core.service.config
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
|
||||||
|
|
||||||
|
/**
|
||||||
|
*CORS配置
|
||||||
|
*
|
||||||
|
* @since 2025-04-02 17:03:41
|
||||||
|
* @author gewuyou
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
open class CorsConfig : WebMvcConfigurer {
|
||||||
|
override fun addCorsMappings(registry: CorsRegistry) {
|
||||||
|
registry.addMapping("/**") // 匹配所有路径
|
||||||
|
.allowedOrigins("*") // 允许所有来源(生产环境建议指定具体域名)
|
||||||
|
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 允许的HTTP方法
|
||||||
|
.allowedHeaders("*") // 允许所有请求头
|
||||||
|
.allowCredentials(false) // 是否允许携带Cookie(true时需要明确指定allowedOrigins,不能为*)
|
||||||
|
.maxAge(3600) // 预检请求缓存时间(秒)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user