JAVA 服务端Spring-boot // 解决No 'Access-Control-Allow-Origin' header is present on the requested resource.

先上轮子:

https://stackoverflow.com/questions/34173432/no-access-control-allow-origin-header-is-present-on-the-requested-resource-io


@SpringBootApplication
@Configuration
public class DatabastobeansApplication {

    public static void main(String[] args) {
        SpringApplication.run(DatabastobeansApplication.class, args);
    }


    //   解决No 'Access-Control-Allow-Origin' header is present on the requested resource.
    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebConfig();
//      return new WebMvcConfigurerAdapter() {
//          @Override
//          public void addCorsMappings(CorsRegistry registry) {
//              registry.addMapping("/**");
//          }
//      };
    }


}

你可能感兴趣的:(JAVA 服务端Spring-boot // 解决No 'Access-Control-Allow-Origin' header is present on the requested resource.)