package com.example.demo.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* 解决异步访问跨域
*/
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
//本应用的所有方法都会去处理跨域请求
registry.addMapping("/**")
//允许远端访问的域名
.allowedOrigins("http://localhost:9876")//这个地址是你所配得前台地址
//允许请求的方法("POST", "GET", "PUT", "OPTIONS", "DELETE")
.allowedMethods("*")
//允许请求头
.allowedHeaders("*");
}
}
el-upload报错Access to XMLHttpRequestthttpxxxx‘ from origin ‘httpxxxx‘ has been blocked by CORS poli
于 2022-03-27 02:32:16 首次发布