当前位置: 首页 > 工具软件 > ta4j-origins > 使用案例 >

credentials to a set of origins, list them explicitly or consider using “allowedOriginPatterns“

亢奇
2023-12-01

1、异常信息:

Caused by: java.lang.IllegalArgumentException: When allowCredentials is true, allowedOrigins cannot contain the special value "*"since that cannot be set on the "Access-Control-Allow-Origin" response header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead.

2、解决办法:
跨域问题,将 allowedOrigins("*") 改为 .allowedOriginPatterns("*")

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedHeaders("*")
                .allowedMethods("*")
                .allowedOriginPatterns("*")
                .allowCredentials(true);
    }
}
 类似资料:

相关阅读

相关文章

相关问答