package com.emergencyrepair.config; import com.emergencyrepair.common.audit.CurrentUserInterceptor; import org.springframework.context.annotation.Configuration; import com.emergencyrepair.system.log.OperationLogInterceptor; import lombok.RequiredArgsConstructor; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @RequiredArgsConstructor @Configuration public class WebConfig implements WebMvcConfigurer { private final CurrentUserInterceptor currentUserInterceptor; private final OperationLogInterceptor operationLogInterceptor; @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(currentUserInterceptor).addPathPatterns("/api/**").order(0); registry.addInterceptor(operationLogInterceptor).addPathPatterns("/api/**"); } @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**") .allowedOriginPatterns("*") .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") .allowedHeaders("*") .allowCredentials(true); } }