What about axios Cross-domain Tip 404?

there is no configuration in the portal file axios.defaults.baseURL only the following configuration
but prompts GET http://localhost:8080/api/movie/top250?start=25&count=25 404 (Not Found) Why?

Index.js

under

config

proxyTable: {
      "/api": {
        target: "http://api.douban.com/v2/",
        changeOrigin: true,
        pathRewrite: {
          "^/api": "/"
        }
      }
    },
import axios from "axios"
mounted () {
    axios.get("/api/movie/top250?start=25&count=25").then(res => {
      console.log(res)
    })
}
Mar.13,2022
The path of

target should also be the same as that of the request url. Only hostname can be different


   proxyTable: {
      // proxy all requests starting with /api to jsonplaceholder
      '/api': {
        target: 'http://api.douban.com/v2/',
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    }
    

the configuration is written like this, and when there is no problem, rerun the project.

Menu