question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CORS Issue AsyncHttpConsumer

See original GitHub issue

Access 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:closed
  • Created 5 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jray-afkcommented, Mar 25, 2021

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.

1reaction
Zarathustra2commented, Feb 11, 2019

@matthiask totally forget about it, @carltongibson maybe reopen the ticket again and @waqasraz could you provide a minimal project for reproducing that issue?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found