Доступ к XMLHttpRequest по адресу «https:/» /sub.domain.com/api/staff/logout» из источника «http://localhost:4200» заблокирован политикой CORS: ответ на предполетный запрос не проходит проверку контроля доступа: нет Заголовок Access-Control-Allow-Origin присутствует в запрошенном ресурсе.
Моя конфигурация выглядит следующим образом:
Код: Выделить всё
@Configuration
@EnableWebMvc
public class WebMvcConfig {
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS").allowedOrigins("*")
.allowedHeaders("*")
.exposedHeaders("Access-Control-Allow-Origin", "Access-Control-Allow-Credentials")
.allowCredentials(true).maxAge(3600);
}
/**
* To add our interceptor into Spring configuration, we need to override
* addInterceptors() method WebMvcConfig class that implements WebMvcConfigurer.
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new AppInterceptor());
}
};
}
}
Подробнее здесь: https://stackoverflow.com/questions/672 ... g-security
Мобильная версия