The direction of the agent

The principle is to request the local port, and the local port requests the cross-domain server. Since the local port is the back-end, there is no cross-domain problem

Resolve cross-domain issues in the development environment

Cross-domain development environment

The cross-domain development environment, that is, in the ** VUe-CLI scaffolding environment under the development of services, we access the interface encountered cross-domain problems, VUe-CLI for us in the local open a service, can help us through this service proxy request **, solve cross-domain problems

This is the reverse proxy for vue-CLI configuration Webpack

The root directory is configured with vue.config.js

The one outside SRC

Module. exports = {devServer: {// exports: {// exports: {// exports: {// exports: {// exports: {// exports: {// exports: {// exports: {// exports: {// exports: {// exports: {// exports: { // localhost:8888/ API/ABC => proxy to another server // local front end = "local back end =" proxy we send requests to another server '/ API ': {target: 'www.baidu.com', // We want the proxy address -- your cross-domain server address changeOrigin: True, // Does this need to be set to true to allow local service proxies across domains? {// reroute localhost:8888/ API /login => www.baidu.com/api/login // replace API with null '^/ API ': '// Suppose we want to change localhost:8888/ API /login to www.baidu.com/login}},}}}Copy the code