Commit d6777cf5 authored by hongguangwu's avatar hongguangwu

Merge remote-tracking branch 'origin/MVP1.7.5' into MVP1.7.5

parents 445579e8 6ac24842
package com.yifu.cloud.plus.v1.yifu.auth.config; package com.yifu.cloud.plus.v1.yifu.auth.config;
import lombok.extern.slf4j.Slf4j; import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import java.util.Collections;
/** /**
* Description: 允许跨域以 * CORS资源共享配置
* *
* @author fxju
* @since JDK 1.8
*/ */
@Slf4j
@Configuration @Configuration
public class CorsConfig implements WebMvcConfigurer { public class CorsConfig {
@Override @Bean
public void addCorsMappings(CorsRegistry registry) { public FilterRegistrationBean filterRegistrationBean() {
registry.addMapping("/**") CorsConfiguration corsConfiguration = new CorsConfiguration();
//是否发送Cookie //1.允许任何来源
.allowCredentials(true) corsConfiguration.setAllowedOriginPatterns(Collections.singletonList("*"));
//放行哪些原始域 //2.允许任何请求头
.allowedOriginPatterns("*") corsConfiguration.addAllowedHeader(CorsConfiguration.ALL);
.allowedMethods(new String[]{"GET", "POST", "PUT", "DELETE"}) //3.允许任何方法
.allowedHeaders("*") corsConfiguration.addAllowedMethod(CorsConfiguration.ALL);
.exposedHeaders("*"); //4.允许凭证
} corsConfiguration.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", corsConfiguration);
CorsFilter corsFilter = new CorsFilter(source);
FilterRegistrationBean<CorsFilter> filterRegistrationBean=new FilterRegistrationBean<>(corsFilter);
filterRegistrationBean.setOrder(-101); // 小于 SpringSecurity Filter的 Order(-100) 即可
return filterRegistrationBean;
}
} }
package com.yifu.cloud.plus.v1.yifu.salary.config; package com.yifu.cloud.plus.v1.yifu.salary.config;
import lombok.extern.slf4j.Slf4j; import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import java.util.Collections;
/** /**
* Description: 允许跨域以 * CORS资源共享配置
* *
* @author fxju
* @since JDK 1.8
*/ */
@Slf4j
@Configuration @Configuration
public class CorsConfig implements WebMvcConfigurer { public class CorsConfig {
@Override @Bean
public void addCorsMappings(CorsRegistry registry) { public FilterRegistrationBean filterRegistrationBean() {
registry.addMapping("/**") CorsConfiguration corsConfiguration = new CorsConfiguration();
//是否发送Cookie //1.允许任何来源
.allowCredentials(true) corsConfiguration.setAllowedOriginPatterns(Collections.singletonList("*"));
//放行哪些原始域 //2.允许任何请求头
.allowedOriginPatterns("*") corsConfiguration.addAllowedHeader(CorsConfiguration.ALL);
.allowedMethods(new String[]{"GET", "POST", "PUT", "DELETE"}) //3.允许任何方法
.allowedHeaders("*") corsConfiguration.addAllowedMethod(CorsConfiguration.ALL);
.exposedHeaders("*"); //4.允许凭证
} corsConfiguration.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", corsConfiguration);
CorsFilter corsFilter = new CorsFilter(source);
FilterRegistrationBean<CorsFilter> filterRegistrationBean=new FilterRegistrationBean<>(corsFilter);
filterRegistrationBean.setOrder(-101); // 小于 SpringSecurity Filter的 Order(-100) 即可
return filterRegistrationBean;
}
} }
...@@ -33,7 +33,6 @@ import java.util.Map; ...@@ -33,7 +33,6 @@ import java.util.Map;
* @author huych * @author huych
* @date 2025-01-10 11:24:38 * @date 2025-01-10 11:24:38
*/ */
@CrossOrigin(origins = "*")
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/tinsuranceunpurchaseapply") @RequestMapping("/tinsuranceunpurchaseapply")
......
...@@ -50,7 +50,7 @@ security: ...@@ -50,7 +50,7 @@ security:
- /salaryEmployeeSelect/getSalaryAccount # 工资条查询明细通过openId控制 - /salaryEmployeeSelect/getSalaryAccount # 工资条查询明细通过openId控制
- /tsalaryatta/ossUploadFile # 工资条查询附件上传 无token - /tsalaryatta/ossUploadFile # 工资条查询附件上传 无token
- /tsalaryatta/ossFileDelete/** # 工资条查询附件上传删除 无token - /tsalaryatta/ossFileDelete/** # 工资条查询附件上传删除 无token
#- /tinsuranceunpurchaseapply/getAuditPageTemp # 临时调试 - /tinsuranceunpurchaseapply/getAuditPageTemp # 临时调试
- /tinsuranceunpurchaseapply/getAuditCount # 临时调试 - /tinsuranceunpurchaseapply/getAuditCount # 临时调试
- /tinsuranceunpurchaseapply/auditTemp # 临时调试 - /tinsuranceunpurchaseapply/auditTemp # 临时调试
- /tauditrecord/getAuditInfoByDomainIdAndAuditType # 临时调试 - /tauditrecord/getAuditInfoByDomainIdAndAuditType # 临时调试
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment