admin管理员组

文章数量:1794759

(跨域问题)Access to XMLHttpRequest at xxx from origin xxx

(跨域问题)Access to XMLHttpRequest at xxx from origin xxx

问题:Access to XMLHttpRequest at ‘localhost:8181/book/findAll’ from origin ‘localhost:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. 解决方法:前端后端都可解决 ①springboot后端: 创建配置类CorsConfig

@Configuration public class CrosConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOriginPatterns("*") .allowedMethods("GET","POST","HEAD","PUT","DELETE") .allowCredentials(true) .maxAge(3600) .allowedHeaders("*"); } }

本文标签: XMLHttpRequestAccessoriginxxx