/** * cors跨域处理 * * @param registry */ @Override public void addCorsMappings ( CorsRegistry registry ) { registry.addMapping( "/**" ) .allowedMethods( HttpMethod.HEAD.name() , HttpMethod.GET.name() , HttpMethod.POST.name() , HttpMethod.PUT.name() , HttpMethod.DELETE.name() , HttpMethod.OPTIONS.name() , HttpMethod.PATCH.name() , HttpMethod.TRACE.name() ) // 允许的域名 .allowedOrigins( "*" ); }
@Override public final void addCorsMappings(final CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("GET", "POST", "DELETE", "PUT", "OPTIONS") .allowedHeaders( "Host", "User-Agent", "X-Requested-With", "Accept", "Accept-Language", "Accept-Encoding", "Authorization", "Referer", "Connection", "Content-Type") .exposedHeaders("header1", "header2") .maxAge(MAX_AGE) .allowCredentials(true); }
@Bean WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/") .allowedOrigins("*") .allowedMethods("POST, GET, OPTIONS, DELETE ,PUT") .allowedHeaders(AUTHORIZATION_HEADER, CONTENT_TYPE_HEADER, X_REQUESTED_WITH_HEADER, ACCEPT_HEADER, ORIGIN_HEADER, AC_REQUEST_METHOD_HEADER, AC_REQUEST_HEADERS_HEADER, AC_ALLOW_ORIGIN_HEADER, AC_ALLOW_CREDENTIALS_HEADER, XXSRFTOKEN, XXSRFTOKEN2) .exposedHeaders(AUTHORIZATION_HEADER, CONTENT_TYPE_HEADER, X_REQUESTED_WITH_HEADER, ACCEPT_HEADER, ORIGIN_HEADER, AC_REQUEST_METHOD_HEADER, AC_REQUEST_HEADERS_HEADER, AC_ALLOW_ORIGIN_HEADER, XXSRFTOKEN, XXSRFTOKEN2) .allowCredentials(true).maxAge(3600); } }; }
/** * Spring4 Cors filter * By default disabled * @return */ @Bean @ConditionalOnProperty(value="appverse.frontfacade.rest.cors.enabled", matchIfMissing=false) public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { String path = apiPath; if (!StringUtils.isEmpty(corsPath)){ path = corsPath; } registry.addMapping(path + "/**") .allowedOrigins(StringUtils.commaDelimitedListToStringArray(allowedOrigins)) .allowedMethods(StringUtils.commaDelimitedListToStringArray(allowedMethods)) .allowedHeaders(StringUtils.commaDelimitedListToStringArray(allowedHeaders)) .allowCredentials(Boolean.valueOf(allowedCredentials)) .maxAge(Long.valueOf(maxAge)); } }; }
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/swagger/swagger-spec.yaml"); if (yonaProperties.getSecurity().isCorsAllowed()) { // Enable CORS for the other resources, to allow testing the API through Swagger UI. registry.addMapping("/**").allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE"); } } }; }
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { // Add CORS header for all path in application registry.addMapping("/**") // .allowedOrigins("*") // .allowedMethods("POST", "GET", "OPTIONS", "DELETE", "PUT", "PATCH") // .maxAge(3600) // .allowedHeaders("x-requested-with", "Content-Type", "accept", "Authorization") .exposedHeaders("Authorization") .allowCredentials(true); } }; }
@Bean @SuppressWarnings("AnonymousInnerClassMayBeStatic") public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/v1/**") .allowCredentials(true) .allowedOrigins(Constants.UrlConstants.ALLOWED_ORIGINS) .allowedMethods("GET", "HEAD", "POST", "PATCH", "DELETE", "OPTIONS"); } }; }
/** * Activation de CORS pour tous les domaines. * * @return Configurateur Spring MVC. */ @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedOrigins("*"); } }; }
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedOrigins("*") .allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS") .allowCredentials(false).maxAge(3600); } }; }
@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedHeaders("*") .allowedMethods("*") .allowedOrigins("*"); }
@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins(crossMapping) .allowedMethods("GET","POST","PUT", "DELETE", "OPTIONS") .allowedHeaders("*") .allowCredentials(true) .maxAge(3600); }
@Bean public WebMvcConfigurer mvcConfigurer() { return new WebMvcConfigurerAdapter() { public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedMethods("GET", "PUT", "POST", "GET", "OPTIONS"); } }; }
@Bean public WebMvcConfigurer corsConfiguration() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**") .allowedMethods(HttpMethod.GET.toString(), HttpMethod.POST.toString(), HttpMethod.PUT.toString(), HttpMethod.DELETE.toString(), HttpMethod.OPTIONS.toString()) .allowedOrigins("*"); } }; }
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedOrigins("*"); } }; }
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedOrigins("http://localhost:4200"); } }; }
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedOrigins("http://localhost:4200"); registry.addMapping("/**").allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "TRACE", "OPTIONS", "PATCH"); } }; }
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedMethods("GET", "POST", "PUT", "DELETE"); } }; }
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { // TODO check if its working registry.addMapping("/**").allowedOrigins("*"); } }; }
@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") .allowCredentials(false) .allowedHeaders("Accept", "Content-Type", "Origin", "authority"); }
@Bean @Conditional(Development.class) public WebMvcConfigurer webMvcConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(final CorsRegistry registry) { registry.addMapping("/**"); } }; }
@Bean public WebMvcConfigurer mvcConfig() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedOrigins("*").allowedMethods("PUT","DELETE","GET","POST"); } }; }
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("http://localhost:4200", "http://localhost:8080") .allowedMethods("GET", "PUT", "POST", "DELETE"); } }; }
@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("POST", "GET", "DELETE", "PUT") .allowCredentials(false).maxAge(3600); }
/** * allow all origins - only for development mode * @return */ @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedMethods("*"); } }; }
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE").allowedOrigins("*") .allowedHeaders("*"); } }; }
@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("*") .allowedHeaders("*") .allowCredentials(false) .exposedHeaders("Authorization"); }
@Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurerAdapter() { @Override public void addCorsMappings(CorsRegistry registry) { // 配置CorsInterceptor的CORS参数 registry.addMapping("/**").allowedOrigins("*").allowCredentials(true).allowedHeaders("*") .allowedMethods("*").maxAge(3600); } }; }
@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("GET", "POST") .allowCredentials(true) .allowedHeaders("origin", "content-type", "accept", "x-requested-with", "authenticate"); }
@Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("*") .allowCredentials(true) .allowedHeaders("origin", "content-type", "accept", "x-requested-with", "X-Authorization", "authenticate", "library"); }
/** * 跨域问题 */ @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedMethods("DELETE", "POST", "GET", "PUT") .allowedOrigins("*"); }