adamchainz / django-cors-headers

Django app for handling the server headers required for Cross-Origin Resource Sharing (CORS)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CORS NOT WHITELISTING IP

rahulroxxx opened this issue · comments

Understanding CORS

  • I have read the resources.

Python Version

3.8.12

Django Version

3.2.0

Package Version

3.7.0

Description

React server is trying to access the resources but it is showing the error as mentioned.

Access to XMLHttpRequest at 'https://<server-url>/api/token/' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

The clue here is:

It does not have HTTP ok status.

Somehow the CORS response does not have status code 200.

Can you see in your server logs what the status code actually is? If there's a crash, please provide the traceback.

Also note one crash has been fixed since the version of django-cors-headers you're using: https://github.com/adamchainz/django-cors-headers/blob/main/HISTORY.rst

Also upgrade your Django version: it may help, but it's a good idea anyway. There have been many bug fixes and security fixes since 3.2.0.

@adamchainz basically we are getting 404 as shown in the request. Thanks!

@adamchainz can you please suggest how we can activate logs for the traceback of the issue related to library?

There's nothing specific to logging requests to django-cors-headers. Just use Django's built-in logging. That's too big of a topic for me to describe here.

Closing the issue because it's not related to django-cors-headers, but your URL configuration.