google-bard-api
google-bard-api copied to clipboard
CORS Issue
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!
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.