-Modus der Anforderung auf 'No-Cors', um die Ressource mit deaktivierten CORs zu holen. Vor dem CORS -Fehler.
Code: Select all
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"com.company.pack"})
@PropertySource("classpath:/app-${spring.profiles.active}.properties")
public class Config implements WebMvcConfigurer {
@Value("${allowed-origins:*}")
// this has https://www.company.com,https://company.com,https://sample.company.com
// printed via a PostConstruct just to confirm and prints correctly.
String allowedOriginsPattern;
@Override
public void addCorsMappings(CorsRegistry registry) {
String[] origins = allowedOriginsPattern.split(",");
registry.addMapping("/**")
.allowedOriginPatterns(origins)
.allowedMethods("GET", "OPTIONS", "POST")
.allowedHeaders(
"content-type",
..... other custom headers
)
.allowCredentials(true);
}
}
< /code>
Auch mit < /p>
ausprobiert.allowedOrigins(origins)
Was fehlt mir?