dev : 合并提交 #41
| @ -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