-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
How to setup ASGI CORS in Django? #8
Comments
What did you try? Generally I wouldn't suggest using this with Django since Django already has very robust CSRF protection built into the core framework itself: https://docs.djangoproject.com/en/4.1/ref/csrf/ |
Is there a way to implement using ours in django? |
A reason is if Django is used with Strawberry GraphQL which provides a parallel view. This has the effect that Django's middleware is not run for all paths (e.g., /graphql/). One option to integrate it is (abbreviated from my implementation):
And then you start the ASGI server with: |
After further research I'd suggest using CORSMiddleware from Starlette. The behavior of this library does not conform to the spec in a few scenarios and that one will and can integrated into asgi Django in a similar manner as stated above. |
I was unable to setup CORS in asgi application . I saw all the instructions but unable to understand where to place them . It didn't work in the base.py .
The text was updated successfully, but these errors were encountered: