Solve the problem of inconsistent front and back end ports of Vue

Solve the problem of inconsistent front and back end ports of Vue

Vue front and back end ports are inconsistent

In the config index.js file

Just import the following code

proxyTable: {
'/api': {
target: 'http://localhost:3000', //The backend interface to be accessed changeOrigin: true,
pathRewrite: {
'^/api': '/'
//The configuration here is a regular expression. The one starting with /api will be replaced with '/api'. If the interface of the backend document is /api/list/xxx
//The front-end API interface is written as: axios.get('/api/list/xxx'), and the actual access after processing is: http://news.baidu.com/api/list/xxx
}
}},

The port number of vue server startup is different every time

Yesterday I ran a project given by a friend on my computer. Since he was using vue3.0 and I was using vue2.5.2, there was an error message when running his project. It might be a version problem. I followed the error message to download the plug-in, and his project worked. But since then, every time I run my project, I find that the port number is different.

Solution:

First download npm install [email protected]

Reinstall dependencies npm install

Restart the project npm run dev

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • How to implement different ports on the front and back ends of Vue
  • Solve the problem of using proxy to configure different ports and IP interfaces in Vue
  • Analysis of solutions to cross-domain problems in vue+springboot front-end and back-end separation projects
  • Solve the problem that the VUE project localhost port server refuses to connect and can only use 127.0.0.1
  • Detailed explanation of the front-end and back-end deployment tutorial based on Vue and Nginx

<<:  Solve the black screen problem after VMware installs Linux system and starts

>>:  A simple method to merge and remove duplicate MySQL tables

Recommend

Search optimization knowledge to pay attention to in web design

1. Link layout of the new site homepage 1. The loc...

How to set background color and transparency in Vue

Background color and transparency settings As sho...

HTML Basics: The basic structure of HTML

The basic structure of HTML hypertext documents is...

Solution to the problem of mysql master-slave switch canal

After configuring VIP, the error message that app...

How to run Linux commands in the background

Normally, when you run a command in the terminal,...

Summary of the dockerfile-maven-plugin usage guide

Table of contents pom configuration Setting.xml c...

Detailed explanation of how to use zabbix to monitor oracle database

1. Overview Zabbix is ​​a very powerful and most ...

Sample code for implementing two-way authentication with Nginx+SSL

First create a directory cd /etc/nginx mkdir ssl ...

How to preview pdf file using pdfjs in vue

Table of contents Preface think Library directory...

CentOS 7 installation and configuration method graphic tutorial

This article records the detailed installation tu...

TypeScript namespace explanation

Table of contents 1. Definition and Use 1.1 Defin...

Vue implements irregular screenshots

Table of contents Image capture through svg CSS p...