首页 > 解决方案 > 我在获取 api 时遇到网络错误。如何解决此错误?

问题描述

这是我的后端 api,

app.get('/google',passport.authenticate('google', { scope: ['profile','email'] }));

这是我的前端抓取,

 axios(`http://localhost:3333/google`, {
      headers: {
        "Content-Type": "application/json",
        "Access-Control-Allow-Origin": "*",
      },
      mode: "cors",
      credentials: "same-origin",
    })
      .then((d) => d.text())
      .catch((e) => console.log({ e }));

标签: node.js

解决方案


推荐阅读