Spring boot 跨域请求问题(403)


 * 设置跨域请求
public class MyConfiguration {
    public FilterRegistrationBean corsFilter() {
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        CorsConfiguration config = new CorsConfiguration();
        config.addAllowedOrigin("*");// 1 设置访问源地址
        config.addAllowedHeader("*");// 2 设置访问源请求头
        config.addAllowedMethod("*");// 3 设置访问源请求方法
        source.registerCorsConfiguration("/**", config);
        FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
        return bean;

You may also like...

1 Response

  1. cialis说道:

    you are truly a excellent webmaster. The website
    loading velocity is incredible. It sort of feels that you
    are doing any distinctive trick. Furthermore, The contents are masterwork.
    you have done a fantastic job on this topic!


电子邮件地址不会被公开。 必填项已用*标注