1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| 在vue.config.js中输入以下代码 module.exports = { publicPath: process.env.NODE_ENV === 'production' ? './' : '/', outputDir: 'dist', assetsDir: "assets", productionSourceMap: false, filenameHashing: false, lintOnSave: true, devServer: { open: false, port: 8080, https: false, hotOnly: false, proxy: { '/api': { target: 'http://47.106.241.182:8082', secure: false, ws: true, changeOrigin: true, pathRewrite:{ '^/api':'' } } }, } }
或者在vite.config.js中加入以下代码 server: { port: '3000', proxy: { '/api': { target: 'http://localhost:8080/', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, '') } } }
|