blob: 193c76cd5b0449ce43483df236e7b556bd4111ba [file] [log] [blame]
Seamher8ba71e02025-06-09 22:38:35 +08001package com.g9.g9backend.config;
2
3import org.slf4j.Logger;
4import org.slf4j.LoggerFactory;
5import org.springframework.context.annotation.Configuration;
6import org.springframework.web.servlet.config.annotation.CorsRegistry;
7import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
8
9/**
10 * WebConfig 类用于配置 Spring MVC 的拦截器和 CORS 设置
11 *
12 * @author Seamher
13 */
14@Configuration
15public class WebConfig implements WebMvcConfigurer {
16
17 private static final Logger logger = LoggerFactory.getLogger(WebConfig.class);
18
19 /**
20 * 配置 CORS 设置
21 *
22 * @param registry CORS 注册表
23 */
24 @Override
25 public void addCorsMappings(CorsRegistry registry) {
26 logger.info("Configuring CORS mappings");
27 registry.addMapping("/**")
28 .allowedOrigins("*")
29 .allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")
30 .allowedHeaders("*");
31 logger.info("CORS mappings configured to allow all origins, methods, and headers");
32 }
33
34}