nginx-s3-gateway icon indicating copy to clipboard operation
nginx-s3-gateway copied to clipboard

Add CORS headers, configurable with a CORS_ALLOW_ALL setting

Open worace opened this issue 3 years ago • 3 comments

worace avatar Oct 14 '22 21:10 worace

https://github.com/nginxinc/nginx-s3-gateway/issues/62

worace avatar Oct 14 '22 21:10 worace

Example before/after:

$ curl -I -X OPTIONS http://localhost/user/horace/wof_neighborhoods.fgb
HTTP/1.1 405 Not Allowed
Server: nginx
Date: Fri, 14 Oct 2022 21:27:09 GMT
Content-Type: text/html
Content-Length: 150
Connection: keep-alive
Allow: GET, HEAD

$ curl -I -X OPTIONS http://localhost/user/horace/wof_neighborhoods.fgb
HTTP/1.1 204 No Content
Server: nginx
Date: Fri, 14 Oct 2022 21:27:23 GMT
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range
Access-Control-Max-Age: 1728000
Content-Length: 0

worace avatar Oct 14 '22 21:10 worace

Thank you for the PR! I see it is still a draft, so you must be still iterating. All in all this looks, good. I do wonder if it is possible to add an integration test that makes sure that CORS is working as per expectation when enabled.

dekobon avatar Oct 17 '22 16:10 dekobon

These changes look solid to me! Is there any progress on this review? @dekobon This would be a very nice feature to have , so using the stubs wouldn't be necessary :)

dav-pascual avatar Nov 25 '22 12:11 dav-pascual

Hi @dav-pascual and @worace my apologies for the late response. After a lot of thinking, I'd like to implement this in the nginx configuration rather than co-locate it in the AWS/S3 specific JS file.

I've created this PR and I would like your review and testing on it if possible.

dekobon avatar Nov 29 '22 18:11 dekobon

@dekobon I think that sounds like a great approach; probably more similar to what other users with prior familiarity with nginx would expect

worace avatar Nov 30 '22 18:11 worace