后端项目地址:https://github.com/Glong97/Redis-Applications
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
devServer: {
proxy: {
'/api': {
// 此处的写法,目的是为了将 /api 替换成你所访问的服务器地址
target: 'http://localhost:8204/api',
// 允许跨域
changeOrigin: true,
ws: true,
pathRewrite: {
'^/api': ''
}
}
}
}
})
- target:修改为你后端服务的地址和端口,若后端服务在本机,并且端口号为8204则不用改
npm install
npm run serve