wavded / ogre

ogr2ogr geojson-focused web client
http://ogre.adc4gis.com
MIT License
266 stars 78 forks source link

Respond to OPTIONS requests with CORS headers to allow preflighted requests #22

Closed bilts closed 10 years ago

bilts commented 10 years ago

Browsers may preflight CORS requests by issuing OPTIONS requests. They will refuse to perform the request if they don't see the CORS headers. See: https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS#Preflighted_requests

In Ogre, Express is using the default OPTIONS handler, bypassing the CORS code. curl -XOPTIONS -v 'http://ogre.adc4gis.com/convert' demonstrates that no 'Access-Control-*' headers are being returned.

This pull request updates Ogre to respond to OPTIONS on /convert and /convertJson by returning CORS headers. It sets the "Allow" header and response body to "POST" to remain compatible with the current (default) behavior.

wavded commented 10 years ago

Thanks @bilts , merged!