gcp-storage-emulator
gcp-storage-emulator copied to clipboard
Add an OPTIONS response
This proposal would add support OPTIONS request with a simple permissive response. My hope is that this will allow for integration with SSL systems.
For #179. cc @ngbrown
Would you mind adding a test or few for the OPTIONS method?
Sure. Is there an example in the repository now you'd like me to emulate?
I believe I have added a test for you, @oittaa, but the workflow needs your permission to run.
I've made some changes to address issues in the tests and linter.
This would be very helpful for our team as well, currently blocked on using this locally due to CORS issues.
This would be very helpful for our team as well, currently blocked on using this locally due to CORS issues.
Funny seeing you here haha. Literally just ran into this issue with our local dev setup and this is where I came to try and figure it out.
More generally speaking, anything we can do to help speed up the integration of this feature into the library @oittaa?
Very appreciative of all the work you put into this library. Hard to believe that google doesn't support anything like this natively in their storage client library.
I'd love to have somebody test my PR to see if it works for them.
I'd love to have somebody test my PR to see if it works for them.
Will do! I'll let you know once I've tested things.
@palewire not sure if your use case is related to CORS or not, but when I was testing this, I ran into the issue that even though the options were being set correctly (after the changes in my other comment), I was still running into issues because subsequent responses didn't use the Access-Control-Allow-Origin
header. If you read the COR's documentation here you can learn more about this.
Not sure if we would classify this within the scope of this PR or as something separate (though the changes to options are required first to make this work).
As a quick and dirty fix, in my own local installation of the package, I added
if method == "GET":
response['Access-Control-Allow-Origin'] = "*"
Right before the return statement in the method handle
of the Router
class in server.py
. This definitely isn't the right way to implement this in a generalizable approach, but it works for my use case.
One thought I had would be to
- Add a top level arg to the Server init method called
enable_cors
- If this flag is enabled (False by default to be backwards compatible), we would add the header
Access-Control-Allow-Origin: *
to any outgoing response, regardless of the method (GET, POST, etc.) of the incoming request.
This could also be made more complex by enabling cors only for specific buckets, rather than for the emulator as a whole. But for my purposes this simple approach would suffice.
Curious to hear @oittaa 's perspective on what the right way to implement this would be.
@oittaa bumping this
Is there a reason this hasn't been merged?