From d43089fad2737b8b4cf245daad0be4588e30dc8b Mon Sep 17 00:00:00 2001 From: 05412 <2738076308@qq.com> Date: Thu, 25 Jul 2024 18:15:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B7=A8=E5=9F=9F=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../surl/surl/cfg/security/CrossOriginConfig.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/dev/surl/surl/cfg/security/CrossOriginConfig.kt diff --git a/src/main/java/dev/surl/surl/cfg/security/CrossOriginConfig.kt b/src/main/java/dev/surl/surl/cfg/security/CrossOriginConfig.kt new file mode 100644 index 0000000..2889ab8 --- /dev/null +++ b/src/main/java/dev/surl/surl/cfg/security/CrossOriginConfig.kt @@ -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) + } + } +} \ No newline at end of file