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

HTML+CSS+jQuery imitates the search hot list tab effect with screenshots

Copy code The code is as follows: <!DOCTYPE ht...

A brief discussion on how to learn JS step by step

Table of contents Overview 1. Clearly understand ...

How to find websites with SQL injection (must read)

Method 1: Use Google advanced search, for example...

Solution to index failure in MySQL due to different field character sets

What is an index? Why create an index? Indexes ar...

Summary of Vue3 combined with TypeScript project development practice

Table of contents Overview 1. Compositon API 1. W...

Mysql Sql statement exercises (50 questions)

Table name and fields –1. Student List Student (s...

Vue encapsulation component tool $attrs, $listeners usage

Table of contents Preface $attrs example: $listen...

Detailed explanation of the use of Docker commit

Sometimes you need to install certain dependencie...

Docker installation and deployment example on Linux

After reading the following article, you can depl...

Summary of 6 solutions for implementing singleton mode in JS

Preface Today, I was reviewing the creational pat...

How to enable MySQL remote connection

For security reasons, MySql-Server only allows th...

CSS specification BEM CSS and OOCSS sample code detailed explanation

Preface During project development, due to differ...

Web front-end development CSS related team collaboration

The front-end development department is growing, ...