node.js - 我在获取 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 }));
解决方案
推荐阅读
- database - 如何加快具有许多布尔字段的 mongo db 查询?
- c# - 创建一个指向任意数据的位域类——这安全吗?
- html - 如何从 JSON 中添加文本“
“?
- javascript - 如何找到确定特定像素颜色的 CSS/HTML 规则
- javascript - 通过 config.json 文件注册时,导入语句会破坏 typeorm 实体
- python - 如何正确分组字符串中的项目?
- html - 响应式步进栏,桌面垂直,移动水平。如何?
- flutter - Draggable 和 DragTarget:如何拖动小部件并在 DragTarget 中重建它?
- variables - 大写会影响golang中功能块内的变量吗?
- reactjs - Enzyme 内部错误:Enzyme 需要配置适配器,但没有找到