无法向第三方应用程序发出帖子请求

时间:2021-02-06 11:28:07

标签: node.js axios cors postman

我已经在我的 nodeJs 后端编写了这段代码

  const url = "localhost:8080/job/test/build";
  const username = "admin";
  const password = "116c197495ef372f129b85a8a2ca4aadc2";
  const token = Buffer.from(`${username}:${password}`, "utf8").toString(
    "base64"
  );
  const data = {
  }
  axios
    .post(url, {
      headers: {
        Authorization: `Basic ${token}`,
      },
    }) 
    .then((response) => res.send(response)).catch((e) => {console.log(e)});

我收到以下错误

The Error I'm getting

具有相同凭据的相同请求正在邮递员中工作。

1 个答案:

答案 0 :(得分:2)

在 url 中使用 http,就像这样"

 const url = "http://localhost:8080/job/test/build";