|
@@ -0,0 +1,30 @@
|
|
|
+package com.github.jfcloud.gene.config;
|
|
|
+
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
|
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author zj
|
|
|
+ * @date 2022/6/20
|
|
|
+ */
|
|
|
+@Configuration
|
|
|
+public class CorsConfig implements WebMvcConfigurer {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addCorsMappings(CorsRegistry registry) {
|
|
|
+ //解决跨域问题
|
|
|
+ registry.addMapping("/**")
|
|
|
+ .allowedOrigins("*")
|
|
|
+ .allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS")
|
|
|
+ .allowedHeaders("*")
|
|
|
+ .exposedHeaders("access-control-allow-headers",
|
|
|
+ "access-control-allow-methods",
|
|
|
+ "access-control-allow-origin",
|
|
|
+ "access-control-max-age",
|
|
|
+ "X-Frame-Options")
|
|
|
+ .allowCredentials(false)
|
|
|
+ .maxAge(3600);
|
|
|
+ WebMvcConfigurer.super.addCorsMappings(registry);
|
|
|
+ }
|
|
|
+}
|