问题
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
then I got this problem:
回答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