|
|
il y a 1 an | |
|---|---|---|
| .hbuilderx | il y a 1 an | |
| .vite | il y a 1 an | |
| common | il y a 1 an | |
| pages | il y a 1 an | |
| service | il y a 1 an | |
| static | il y a 1 an | |
| uni_modules | il y a 1 an | |
| utils | il y a 1 an | |
| .env.development | il y a 1 an | |
| .gitignore | il y a 1 an | |
| App.vue | il y a 1 an | |
| README.md | il y a 1 an | |
| index.html | il y a 1 an | |
| main.js | il y a 1 an | |
| manifest.json | il y a 1 an | |
| pages.json | il y a 1 an | |
| uni.promisify.adaptor.js | il y a 1 an | |
| uni.scss | il y a 1 an | |
| vite.config.js | il y a 1 an |
框架:uniapp
版本:vue3 + hbuilder 4.29
配置代理实质是配置vite,因此在根目录下创建一个vite.config.js文件,并添加如下配置
import {
defineConfig
} from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
export default defineConfig({
plugins: [uni()],
server: {
proxy: {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}
}
}
});
说明:
参考
* 在uniapp Vue3版本中如何解决web/H5网页浏览器跨域的问题 * 【彻底搞懂】vite proxy如何解决跨域问题