Unable to redirect to fitbit OAuth2 endpoint

守給你的承諾、 提交于 2020-05-23 10:51:11

问题


I am trying to get authorize from Fitbit. when I use Oauth2.0

frontend angular4

getAuthFromFitbit() {
this.http.get(this.BASE_URL + "/fitbit").subscribe(res => {
  console.log(res.json());
});}

backend node.js

IDE capture of code

then I got this problem: Eror message


回答1:


The error you see in the browser console is coming from a fitbit request, not from your server. Setting headers on your server will not help much in your case.




回答2:


This is a Cross Origin Resource Sharing issue. You need to disable CORS in your browser.




回答3:


i use this when front and back is not in same server.

app.use(function (req, res, next) {
  res.header('Access-Control-Allow-Origin', "*");
  res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
  res.header('Access-Control-Allow-Headers', 'Content-Type');
  next();
})

Could you try this.



来源:https://stackoverflow.com/questions/46822111/unable-to-redirect-to-fitbit-oauth2-endpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!