跨域 同源策略
1 vue.config.js 配置
target 替换 之前的 baseURL
2 baseURL 改为
const baseURL = '/api'
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
devServer: {
proxy: {
'/api': {
target: 'http://park.puyizu.com/', //这里填入你要请求的接口的前缀
ws: true, //代理webSocked
changeOrigin: true, //虚拟的站点需要更管origin
secure: true, //是否https接口
pathRewrite: {
'^/api': '', //重写路径
},
},
},
},
})
跨域 同源策略
最新推荐文章于 2024-05-23 04:55:12 发布