Skip to content
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

CORS Issue #10

Open
Nineswiss opened this issue Jun 7, 2023 · 1 comment
Open

CORS Issue #10

Nineswiss opened this issue Jun 7, 2023 · 1 comment

Comments

@Nineswiss
Copy link

I am running a React frontend an when I try to post I get:
Access to XMLHttpRequest at 'http://localhost:8000/ask' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I am new (very) to python so any help would be appreciated!

@caw083
Copy link

caw083 commented Jul 21, 2023

its the trouble of cors you need make the cors white list in django

may be try this

INSTALLED_APPS = [
# ...
'corsheaders',
# ...
]

MIDDLEWARE = [
# ...
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
# ...
]

CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_WHITELIST = [
'http://localhost:3000',
# Add any other allowed origins here
]
After making these changes, restart your backend server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants