1. Solution 1.1 Describing the interface context-path The two backend interface service request prefixes are as follows:
1.2 vue.config.js configuration devServer: { port: 8005, proxy: { // First server configuration '/bryant': { target: 'http://localhost:8081, ws: true, changeOrigin: true, pathRewrite: { '^/bryant': '/bryant' } }, // Second server configuration '/': { target: 'http://localhost:8082', ws: true, changeOrigin: true, pathRewrite: { '^/': '/' } } } } 1.3 axios modification // api base_url, set prefix does not exist const BASE_URL = '' // Create an axios instance const service = axios.create({ baseURL: BASE_URL, timeout: 6000 // request timeout}) At this time, axios does not need to directly specify the baseUrl configuration 1.4 Sending a request // The request prefix is "/" this.$http.get("/basketball").then(res => { console.log('/', res) }).catch(err => { console.log(err) }) // Request prefix is "bryant" this.$http.get("/bryant/mvp").then(res => { console.log('/bryant', res) }).catch(err => { console.log(err) }) SummarizeIn the case of multiple interface services, if the prefix is "/", it should be placed at the end of the proxy configuration. When proxying, it is searched from top to bottom. If it is placed at the top, other services will also be proxied by this configuration. This is the end of this article about the detailed explanation of the solution of Vue configuration requesting multiple servers. For more relevant Vue configuration requesting multiple servers, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: How to install Mysql5.7 in Centos6
>>: How to set a fixed IP address in CentOS7 virtual machine
The effect to be achieved: When the mouse is plac...
1. Analytical thinking 1. Eliminate the machine...
1. There are many Python version management tools...
This article mainly explains how to install the M...
Today, when verifying the concurrency problem of ...
Dataframe is a new API introduced in Spark 1.3.0,...
Mine is: <!DOCTYPE html> Blog Garden: <!...
Let me start with a question: When writing an HTM...
Use HTML to create complex tables. Complex tables...
Table of contents 1. Introduction 2. Initial Vue ...
Table of contents Introduction Install Display Fi...
Table of contents 1 Introduction to the new opera...
Table of contents Component recursive call Using ...
Table of contents background What is the Metavers...
This article summarizes various ways to implement...