google-bard-api icon indicating copy to clipboard operation
google-bard-api copied to clipboard

CORS Issue

Open Nineswiss opened this issue 1 year ago • 1 comments

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!

Nineswiss avatar Jun 07 '23 06:06 Nineswiss

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.

caw083 avatar Jul 21 '23 08:07 caw083