Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS #43

Open
tadwhitaker opened this issue May 6, 2016 · 3 comments
Open

CORS #43

tadwhitaker opened this issue May 6, 2016 · 3 comments

Comments

@tadwhitaker
Copy link

I'm trying to make a call to the Yelp API, but keep getting the following error:

XMLHttpRequest cannot load https://api.yelp.com/v2/search?term=food&location=new%20york. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 400.

Any suggestions on how to work around this?

@christianalfoni
Copy link
Owner

christianalfoni commented May 9, 2016

I think you rather want to proxy that API call through express @tadwhitaker . It is Yelp not having the necessary headers to you can not do much about that. But Node can be a proxy handling the request.

So:

var request = require('request');
app.get('/yelp', function (req, res) {
  request('/api.yelp.com....', function (error, response) {
    res.send(response.body); // Check request API, do not remember this
  })
});

@Odywan55
Copy link

Can any-body advice me the way of handling server changes, with no rerun the server manualy,
and working with routes on it, thanks a lot !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants