1.写个配置类CorsConfig?(如果不行 可以不写此类 和springcloud的版本有关)
package net.youqu.micro.service.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.reactive.CorsWebFilter; import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; import org.springframework.web.util.pattern.PathPatternParser; * description: * java fhadmin.org Configuration public class CorsConfig { Bean public CorsWebFilter corsFilter() { CorsConfiguration config new CorsConfiguration(); config.addAllowedMethod( * config.addAllowedOrigin( * config.addAllowedHeader( * UrlBasedCorsConfigurationSource source new UrlBasedCorsConfigurationSource(new PathPatternParser()); source.registerCorsConfiguration( /** , config); return new CorsWebFilter(source); }
2. 配置?application.properties 方式
#--------gateway配置-------- #跨域配置 spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowedOrigins * spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowedHeaders * spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowedMethods * spring.cloud.gateway.globalcors.corsConfigurations.[/**].allowCredentials true
yaml 方式
spring: cloud: gateway: globalcors: corsConfigurations: [/**] : allowCredentials: true allowedHeaders: * allowedMethods: * allowedOrigins: *
?
发布周期如今已经成为网站应用程序开发的关键指标之一。在动态变化的业务环境中...
激活,破解码,IDEA 2021.1,idea 强烈推介IDEA2020.2破解激活,IntelliJ IDEA 注册...
在日常开发过程中使用kafka来实限流削峰作用但是往往kafka会存放多份副本来防止...
Vue Router 的作用 实现基本的组件之间的路由 vue 是 Vue Router 是 Vuejs 官方...
近期,随着春节档电影《你好,李焕英》的热映以及片中出现的贾玲母亲年轻时旧照...
Prettier 是一款开箱即用的代码格式化工具 主要特点是配置简单、便于集成、支持...
前言 你好,我是A哥(YourBatman)。 有一个观点: 若一个Java开发者能把IDEA玩得6...
租用服务器你需要考虑的安全问题 服务器租用 是企业选择服务器的常用方式之一,...
本文转载自微信公众号「小姐姐味道」,作者姐养狗2号 。转载本文请联系小姐姐味...
腾讯云轻量应用服务器通过VNC搭建Ubuntu图形界面 轻量应用服务器提供的Linux系统...