arco-design-pro-vue
arco-design-pro-vue copied to clipboard
能不能加个跨域的例子
trafficstars
- [ ] I'm sure this does not appear in the issue list of the repository
Basic Info
What are the similar cases of this feature
无
What problem does this feature solve?
加个跨域的配置
修改项目目录config/vite.config.dev.ts中server配置
server: {
open: true,
fs: {
strict: true,
},
// 增加反向代理,跨域
proxy: {
'/api': {
target: 'http://127.0.0.1:8990/',
changeOrigin: true, // 允许跨域
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
修改项目目录config/vite.config.dev.ts中服务器配置
server: { open: true, fs: { strict: true, }, // 增加反向代理,跨域 proxy: { '/api': { target: 'http://127.0.0.1:8990/', changeOrigin: true, // 允许跨域 rewrite: (path) => path.replace(/^\/api/, ''), }, }, },
加了跨域这个配置,还是没有生效
在axios 切面这里加个前缀会好一点
@981433814 是的,要处理一下VITE_API_BASE_URL,开发环境中可以直接把.env.development中VITE_API_BASE_URL注释掉
@981433814 如果是开发环境三件事要处理。1、关闭对应的mock接口。2、拦截器的baseUrl根据自己的环境处理一下。3、添加vite的proxy。
@981433814 如果是开发环境三件事要处理。1、关闭对应的mock接口。2、拦截器的baseUrl根据自己的环境处理一下。3、添加vite的proxy。
你好,我新增一个页面内容,然后我想保留其他的mock借口,新页面的在哪关闭mock接口呢?
