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

Should CORS deny access from curl requests? #8

Closed
facultymatt opened this issue Sep 27, 2013 · 1 comment
Closed

Should CORS deny access from curl requests? #8

facultymatt opened this issue Sep 27, 2013 · 1 comment

Comments

@facultymatt
Copy link

I'm attempting to use the CORS module to block curl requests (or other rest client requests, such as chrome's excellent Postman). But it's not working.

Im guessing that CORS is only respected when making a request from a browser, and that a server to server request not protected with cors. If this is correct, how would I block a cross server request?

@troygoode
Copy link
Member

The node-cors library currently short-circuits and performs no validation if no Origin HTTP header is passed in; this is why curl requests are going through correctly. The reason this is done is that if you were to restrict requests to say, example.com, a user could still easily spoof this in curl like so:

$ curl -H "Origin: example.com" www.yourapi.com/api/foo

In other words, CORS is not a valid mechanism of protecting against server-to-server requests.

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

2 participants