【问题标题】:Why am I getting CORS Error even after enabling Proxy setting in VueJs while making POST request to mapmyindia apis endpoints?为什么即使在向 mapmyindia apis 端点发出 POST 请求时在 VueJs 中启用代理设置后,我也会收到 CORS 错误?
【发布时间】:2021-08-29 19:35:42
【问题描述】:

错误截图

发布请求代码 (Vuejs)

let PROXY = "http://localhost:8080/";
let URL = PROXY + "api/security/oauth/token?grant_type=client_credentials"

URL += `&client_id=${this.ID}`;
URL += `&client_secret=${this.SECRET}`;

try {
  let res = await axios.post(URL, {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }); 

  console.log(res);
}

catch(err) {
  console.log(err);
}

Vue.config.js(代理设置)

module.exports = {
  devServer: {
    proxy: {
        'https://outpost.mapmyindia.com/': {
          target: "http://localhost:8080/",
          changeOrigin: true
        }
    }
  },
  transpileDependencies: [
    'vuetify'
  ]
}

我最初遇到了与 CORS 相关的错误,所以我使用了这个代理,但即便如此我也收到了这个错误。 StackOverflow 上发布了一些与 vuejs 中的代理设置相关的问题,以消除 CORS 错误,但没有一个可以解决此问题,因此我发布了此问题。

【问题讨论】:

    标签: vue.js post proxy axios


    【解决方案1】:

    这不是 CORS 问题。没有找到资源。你有 404 状态码。

    https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

    【讨论】:

    • 通过 PostMan 我收到了回复。
    猜你喜欢
    • 2018-08-16
    • 2022-01-18
    • 1970-01-01
    • 2019-12-04
    • 2018-12-23
    • 2021-11-07
    • 1970-01-01
    • 2020-04-03
    • 2021-01-01
    相关资源
    最近更新 更多