vue配置 域名src\main.js要与config\index.js一样


var axios = require('axios')
axios.defaults.baseURL = 'http://localhost:2020/api'
// 使请求带上凭证信息
axios.defaults.withCredentials = true


assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': {
target: 'http://localhost:2020',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
},



spring 配置com\evan\gd\config\MyWebConfigurer.java

@Override
public void addCorsMappings(CorsRegistry registry) {
//所有请求都允许跨域,使用这种配置方法就不能在 interceptor 中再配置 header 了
registry.addMapping("/**")
.allowCredentials(true)
.allowedOrigins("http://localhost:8080")
.allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
.allowedHeaders("*")
.maxAge(3600);
}

分类:

技术点:

相关文章: