django / channels

Developer-friendly asynchrony for Django
https://channels.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6.11k stars 800 forks source link

Add CORs middleware #2081

Open rossmeredith opened 8 months ago

rossmeredith commented 8 months ago

Hi

Not sure if I should log this with yourselves or strawberry: https://github.com/strawberry-graphql/strawberry.

I encountered the following problem: using storybook locally on port 6006 I was unable to make a request to my django web app which is using both django-channels and the graphql library strawberry. The reason is the consumer class provided by strawberry doesn't handle the pre-flight request where the method is "OPTION".

Would it be possible to add a CORS middleware to this library?

I found the following which seems to work: https://github.com/hot666666/asgi-cors-strawberry/blob/main/asgi_cors_strawberry/middleware.py

I'd feel better using it though if you guys could validate it in the course of adding it to the channels library.

Let me know if it would be better to log this with strawberry.

Thanks.

rossmeredith commented 6 months ago

Not even a comment?