CORS Issue AsyncHttpConsumer
See original GitHub issueAccess to XMLHttpRequest at 'http://127.0.0.1:8001/test_middleware/' from origin 'http://127.0.0.1:8082' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Adding a header to each send response solve the above problem but I don’t want to add a header to each response.
self.send_response(200, b"xxx"
headers=[
(b"Content-Type", b"application/json"),
(b"Access-Control-Allow-Origin", b"*"),
]
)
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
CORS Issue AsyncHttpConsumer #1662 - django/channels
All the http requests still seem to go through the MIDDLEWARE in settings.py if the application = ProtocolTypeRouter() does not define anything ...
Read more >Developers - CORS Issue AsyncHttpConsumer - - Bountysource
CORS Issue AsyncHttpConsumer. ... has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Read more >Django restframework, Django channels, Ionic 2 - websocket ...
So I installed django-cors-middleware in hope this could solve the problem - well it did not. But I think the app does not...
Read more >Consumers — Channels 4.0.0 documentation
An async version of JsonWebsocketConsumer , available as channels.generic.websocket.AsyncJsonWebsocketConsumer . Note that even encode_json and decode_json are ...
Read more >Django Channels and its production deployment
Generally, it is a really great framework but the only issue with it is that it is synchronous. The solution that we wanted...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah whoops, just took a fresh look at this and realized I was missing the CORSMiddleware component from my wsgi.py as well (implemented about the same as how the asgi.py file looks). Everything is working now and getting no CORS error! Going to leave my previous comment up in case someone else runs into the same problem.
@matthiask totally forget about it, @carltongibson maybe reopen the ticket again and @waqasraz could you provide a minimal project for reproducing that issue?