6

typora国内镜像-配置文件加载顺序-网关的跨域配置

 2 years ago
source link: http://www.hechunbo.com/index.php/archives/428.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

typora国内镜像

typora是一款很好用的makedown编辑器, 但是官网链接国内不能直接访问

可以直接通过下面这个镜像连接下载

https://gitee.com/typora-mirror/Typora-Mirror/releases

spring cloud nacos配置文件加载顺序

service1.yml server.port 4000

common.yml server.port 4001

bootstrap.yml server.port 8067

application.yml server.port 8066

结果是4000

网关的跨域

跨域其实是很常见的问题,在 Spring 中可以简单的写个 @CrossOrigin 或者全局拦截器之类的解决掉,但在 Spring Cloud Gateway 中这行不通,写注解等方式在路由转发时还是会跨域

https://blog.csdn.net/sinat_34200786/article/details/104526244

网关中添加以下类

如果添加了以下类还是报错, 有可能的情况是服务器的跟域设置没有删除或者没有删除干净

@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);
    }
}


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK