Vue-cli agent cross-domain failed

written as in the previous project, I don"t know why the agent could not succeed.

module.exports = {
  dev: {
    // Paths
    assetsSubDirectory: "static",
    assetsPublicPath: "/",
    proxyTable: {
      "/api": {
        target: "http://192.168.0.106:8080/",
        changeOrigin: true,
        pathRewrite: {
          "^/api":"/"
        }
      }
    },

    // Various Dev Server settings
    host: "localhost", // can be overwritten by process.env.HOST
    port: 8087, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: true,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/-sharpdevserver-watchoptions-

    /

dev.env.js

"use strict"
const merge = require("webpack-merge")
const prodEnv = require("./prod.env")

module.exports = merge(prodEnv, {
  NODE_ENV: ""development"",
  API_HOST: ""/api/""
})
 process.env.API_HOST
 /api/
axios.defaults.baseURL = process.env.API_HOST

request interface

Request URL: http://localhost:8087/api/qianbomall/app/login
api

what should my problem be?

Sep.30,2021

1. The proxy you are configuring now means that / api
2 will be removed when forwarding to the backend. So you need to make sure that your backend interface has / api

.
Menu