content: package cn.edu.seig.vibemusic.config;
  
  import org.jetbrains.annotations.NotNull;
  import org.springframework.context.annotation.Bean;
  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 {
      @Bean
      public WebMvcConfigurer corsConfigurer() {
          return new WebMvcConfigurer() {
              @Override
              public void addCorsMappings(@NotNull CorsRegistry registry) {
                  registry.addMapping("/**") // 允许所有路径
                          .allowedOriginPatterns("*") // 允许所有来源（推荐）
                          .allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS") // 加上 OPTIONS
                          .allowedHeaders("*") // 允许所有请求头
                          .exposedHeaders("Authorization") // 允许前端获取 Authorization 头
                          .allowCredentials(true); // 允许携带 Cookie 或 Token
              }
          };
      }
  }
  