Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to solve the inconsistency between front and rear port of vue

Shulou Source: shulou.com Published: 2022-05-31 13:05:38 10月04日 Update

Today, the editor will share with you the relevant knowledge points about how to solve the port inconsistency before and after vue. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.

The front and rear ports of vue are inconsistent.

In the config index.js file

Just introduce the following code

ProxyTable: {'/ api': {target: 'http://localhost:3000',// backend interface changeOrigin: true,pathRewrite: {' ^ / api':'/'/ / the configuration here is a regular expression, and the one starting with / api will be replaced with'/ api'. If the interface of the background document is / api/list/xxx// front-end api interface, write: axios.get ('/ api/list/xxx') What is actually accessed after being processed is: the port number of the http://news.baidu.com/api/list/xxx}}},vue startup server is different each time.

Yesterday, I ran the project given by my friend on my computer. Because he used vue3.0 and I used vue2.5.2, I had an error prompt when running his project, and there was a problem with the possible version. I followed the error prompt to download the plug-in. As a result, his project worked well, but since then, I have found that the port number is different every time I execute my project.

Solution:

Download npm install portfinder@1.0.21 first

Reinstall dependency npm install

Restart the project npm run dev

These are all the contents of this article entitled "how to solve the port inconsistency between front and back of vue". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Tags: Project knowledge article consistency content slogan interface error prompt run different big code front-end method background most good practical that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi OPPO Reno vpn Shulou Information Xiaomi