新增跨域支持

This commit is contained in:
05412 2024-07-25 18:15:21 +08:00
parent b0313feff9
commit d43089fad2

View File

@ -0,0 +1,17 @@
package dev.surl.surl.cfg.security
import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@Configuration
open class CrossOriginConfig : WebMvcConfigurer {
override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**").apply {
allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
allowedHeaders("*")
allowedOrigins("*")
maxAge(3600)
}
}
}