在vue中同时跑两个服务配置和跨域问题的配置

1:同时跑两个服务配置: 1:cnpm i concurrently -D 2:在package.json中。

"scripts": {
     "serve": "vue-cli-service serve",
     "build": "vue-cli-service build",
     "server": "nodemon server.js",
     "dev": "concurrently \"npm run serve\" \"npm run server\" "
 }

2:跨域问题的配置 axios: 在vue.config.js中配置:

module.exports = {
    devServer: {
		proxy: { // 跨域    协议 域名 端口
			'/api': {
					target: "http://localhost:8099/",
					ws: true,
					changOrigin: true,
					pathRewrite: {
					'^/api': ''
						}
				}
			}
		}
	}
发布了10 篇原创文章 · 获赞 0 · 访问量 200

猜你喜欢

转载自blog.csdn.net/weixin_45178761/article/details/103934526