From 1775aeff892210ea956ef60d4e114ad46cf714e7 Mon Sep 17 00:00:00 2001 From: zhangdaiscott Date: Tue, 25 Jul 2023 16:09:39 +0800 Subject: [PATCH] =?UTF-8?q?---author:scott---date:2022-07-25---for:demo?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E6=94=AF=E6=8C=81=E8=B7=A8=E5=9F=9F=EF=BC=8C?= =?UTF-8?q?=E6=96=B9=E4=BE=BF=E5=89=8D=E7=AB=AF=E5=AF=B9=E6=8E=A5=E8=B0=83?= =?UTF-8?q?=E8=AF=95--?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/CustomCorsConfiguration.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 jimureport-example/src/main/java/com/jeecg/modules/jmreport/config/CustomCorsConfiguration.java diff --git a/jimureport-example/src/main/java/com/jeecg/modules/jmreport/config/CustomCorsConfiguration.java b/jimureport-example/src/main/java/com/jeecg/modules/jmreport/config/CustomCorsConfiguration.java new file mode 100644 index 0000000..8a3e365 --- /dev/null +++ b/jimureport-example/src/main/java/com/jeecg/modules/jmreport/config/CustomCorsConfiguration.java @@ -0,0 +1,18 @@ +package com.jeecg.modules.jmreport.config; + +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 CustomCorsConfiguration implements WebMvcConfigurer { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") // 所有接口 + .allowCredentials(true) // 是否发送 Cookie + .allowedOriginPatterns("*") // 支持域 + .allowedMethods(new String[]{"GET", "POST", "PUT", "DELETE"}) // 支持方法 + .allowedHeaders("*") + .exposedHeaders("*"); + } +} \ No newline at end of file