forked from qq1244/vue-beta
主要改了路径,还有vite.config.ts配置后端链接
This commit is contained in:
@@ -15,4 +15,18 @@ export default defineConfig({
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
},
|
||||
},
|
||||
})
|
||||
server: {
|
||||
host: '0.0.0.0', // 允许局域网访问(可选)
|
||||
port: 5173, // 修改端口号(默认是 5173)
|
||||
open: true, // 启动项目时自动打开浏览器
|
||||
|
||||
// 配置代理解决跨域问题
|
||||
proxy: {
|
||||
'/api': { // 以/api开头的请求会被代理
|
||||
target: 'http://localhost:8080', // 目标后端服务器地址(如Spring Boot服务)
|
||||
changeOrigin: true, // 开启跨域:请求头中的host会被设置成target
|
||||
rewrite: path => path.replace(/^\/api/, '') // 重写路径,去掉开头的/api
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user