#
Junjie
2025-05-19 0fc62ab3d5d038235b328d91cda0192a34617fb9
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/config/WebConfig.java
@@ -1,9 +1,11 @@
package com.zy.asrs.wcs.common.config;
import com.zy.asrs.wcs.utils.Utils;
import com.zy.asrs.wcs.common.constant.Constants;
import com.zy.asrs.wcs.utils.CommonUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.AsyncHandlerInterceptor;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -28,10 +30,21 @@
        return new AsyncHandlerInterceptor(){
            @Override
            public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
                Utils.cors(response);
                CommonUtils.cors(response);
                return true;
            }
        };
    }
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOriginPatterns("*")
                .allowedHeaders("*")
                .exposedHeaders(Constants.TOKEN_HEADER_NAME)
                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH")
                .allowCredentials(true)
                .maxAge(3600);
    }
}