add: 跨域

This commit is contained in:
kkunkka
2025-10-14 22:00:52 +08:00
parent 1a71904608
commit 8439653082
2 changed files with 21 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
package com.dota.nexus.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedHeaders("*")
.allowCredentials(true)
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.maxAge(3600);
}
}