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.
The translation is as follows:
Solution: cross domain configuration error, replace . Allowedorigins
with . Allowedoriginpatterns
.
Before revision:
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
/**
* Open cross-domain
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
// Set the routes that are allowed across the domain
registry.addMapping("/**")
// Set the domain name that allows cross-domain requests
.allowedOrigins("*")
// whether to allow certificates (cookies)
.allowCredentials(true)
// set the allowed methods
.allowedMethods("*")
// Allowed time across domains
.maxAge(3600);
}
}
After modification:
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
/**
* Open cross-domain
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
// Set the routes that are allowed across the domain
registry.addMapping("/**")
// Set the domain name that allows cross-domain requests
.allowedOriginPatterns("*")
// whether to allow certificates (cookies)
.allowCredentials(true)
// Set the allowed methods
.allowedMethods("*")
// Allowed time across domains
.maxAge(3600);
}
}
Read More:
- Gateway Error: allowedOrigins cannot contain the special value “*“
- [Solved] Kafka Error: is/are not present and missingTopicsFatal is true
- [Solved] Springboot2.x ElasticSearch Error: availableProcessors is already set to [4], rejecting [4]
- Initializingbean Interface & Applicationcontextaware Interface in Springboot
- [Solved] SpringBoot Microservices: Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded dat
- [Solved] Springboot Error: swagger-UI/index.html Access Error 404
- Springboot startup error: err config is disabled command (Redis Disables Config command)
- [Solved] SpringBoot Task Error: Unexpected error occurred in scheduled task
- jasypt springboot Error: Error creating bean with name ‘enableEncryptablePropertySourcesPostProcessor’ defined in class path resource
- Mybatisenumtypehandler upgrade error of mybatis plus
- NULL value exception occurs when freemarker renders the page globally in the springboot project
- SpringBoot+Swagger Error: 403 Forbidden [How to Solve]
- [Solved] Springboot Error: Error creating bean with name ‘dataSource‘ defined in class path resource
- Springboot startup error: Field elasticsearchRestTemplate in cn.lili.modules.material.serviceImpl.QrMaterialServiceImpl required a bean of type
- [Solved] springboot Error: Error creating bean with name ‘configurationPropertiesBeans‘ defined in class path
- [Solved] SpringBoot Startup Error: Description:Web server failed to start. Port 9090 was already in use.(win10)
- Springboot controls the startup of rabbitmq through configuration files
- [Solved] SpringBoot Project Startup Error: Field userMapper in com.demo.controller.MemberController required a bean of type ‘c
- SpringBoot integrates Es error: Error creating bean with name ‘restHighLevelClient‘ defined in class path resource
- Using mybatis statement.getGenreatedKeys(); usegeneratedkeys = “true”; using self incrementing primary key to get primary key value policy and Oracle do not support self incrementing, Oracle uses sequence