-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[WIP] Add a fairing for CORS support #930
Conversation
I haven't looked much at the implementation yet, partly because of the large diff. Have you seen https://github.com/lawliet89/rocket_cors or @SergioBenitez's Personally, I think it would be reasonable to provide a "works for the majority" CORS implementation in
That is unfortunate. It shouldn't be too hard to "undo" entire trees that had format-only chages (e.g. |
Closing due to inactivity (but this is something that we would like, heeding @jebrosen's commentary above). |
I've been working on another project, but now I'm back to rust web :).
Does this mean that CORS should be implemented as a I don't know the right answer so interested to hear thoughts. |
I've thought about this some more, and I think This would require having a way to say "stop and return a response now" in the request part of the fairing. |
@derekdreery I agree, and it's planned, but doing it the way other frameworks do it is not a path we'd like to follow for many reasons. See my commentary in #749 (comment) for more. |
This commit adds a fairing to support CORS.
It works by adding CORS headers to all responses, and also catching 404 OPTIONS requests - returning a 200 response with the correct cors headers as per configuration.
It probably needs some work on the docs before it is merged, and also I didn't realise that my text editor runs
cargo fmt
by default, so either a separate commit needs to go in to just runcargo fmt
on the existing codebase, or I need to revert all those changes :'(.I'm opening it now to see how you feel about the approach. It works well for the project I'm using it in, but I'm interested to see if that is replicated in other projects.