r0man / ring-cors

Ring middleware for Cross-Origin Resource Sharing.
http://github.com/r0man/ring-cors
169 stars 44 forks source link

not allowed? requests return nil #11

Closed shmish111 closed 7 years ago

shmish111 commented 8 years ago

If a request isn't allowed? then nil is returned as a response. There should be something better (although not sure what response exactly, perhaps just a 403)

pesterhazy commented 8 years ago

Same problem here: nil is not a valid return value, it triggers an NPE:

java.lang.NullPointerException: Ring handler returned nil
gbuisson commented 7 years ago

I think the correct behavior, instead of returning nil should be to return the original result of the handler (without adding CORS headers). This way it would trigger the CORS error on the browser and improve feedback.

On a project I'm working on, it returned nil thus triggering a 404 without any other hint, it took me some time to figure out it was due to an issue with this middleware.