0
点赞
收藏
分享

微信扫一扫

When allowCredentials is true, allowedOrigins cannot contain the special value “*“

林塬 2022-03-12 阅读 105

springBoot 2.1.2.RELEASE升级到springBoot 2.5.10报
When allowCredentials is true, allowedOrigins cannot contain the special value “*“
增加一个配置类就可以解决问题

package com.example.springboot.config;
 
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
 
@Configuration
public class CorsConfig extends WebMvcConfigurerAdapter {
 
    static final String ORIGINS[] = new String[]{"GET", "POST", "PUT", "DELETE"};
 
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").
                allowedOriginPatterns("*").
                allowCredentials(true).
                allowedMethods(ORIGINS).
                maxAge(3600);
    }
    }

参考:https://blog.csdn.net/qq_41822960/article/details/119873880

举报

相关推荐

0 条评论