Skip to content
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

[Question] How to handle OPTIONS preflight #4517

Closed
Cluster2a opened this issue Dec 21, 2024 · 3 comments
Closed

[Question] How to handle OPTIONS preflight #4517

Cluster2a opened this issue Dec 21, 2024 · 3 comments
Labels
area/restful Categorizes issue or PR as related to restful apis.

Comments

@Cluster2a
Copy link

Hey, I am trying to figure out, how to handle CORS, especially the OPTIONS preflight.

I tried to implement middleware that returns HTTP.StatusNoContent if an OPTIONS call is being made, but I always get a 405.

The framework is not processing the request as there is no such route.

What is the general approach to handling CORS?

Best - Alex

@kevwan
Copy link
Contributor

kevwan commented Dec 21, 2024

Use rest.WithCors, rest.WithCorsHeaders or rest.WithCustomCors.

@kevwan kevwan added the area/restful Categorizes issue or PR as related to restful apis. label Dec 21, 2024
@Cluster2a
Copy link
Author

@kevwan, thanks a lot! I think this should be documented somewhere.

@kevwan
Copy link
Contributor

kevwan commented Dec 22, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/restful Categorizes issue or PR as related to restful apis.
Projects
None yet
Development

No branches or pull requests

2 participants