pratiksinghchauhan / django_react_socialauth

Handle social login with react and Django
MIT License
36 stars 11 forks source link

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en_US.sazTpAB7NWc.O/m=auth2/rt=j/sv=1/d=1/ed=1/am=wQE/rs=AGLTcCMGRnMhese6OTxesnN0rDvhruAGIg/cb=gapi.loaded_0. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). #3

Open patilkrunal opened 3 years ago

patilkrunal commented 3 years ago

image image image image

How do i solve this issue?

pratiksinghchauhan commented 3 years ago

Can you describe what led to this issue?

patilkrunal commented 3 years ago

the social auth token for google works perfectly when implemented in django via templates. but when implemented it via react frontend it gave this error. i guess in settings.py of django we have corsheaders mentioned. but is there any way to whitelist domains in react so that this Cross-Origin Request Blocked: error can be resolved.

pratiksinghchauhan commented 3 years ago

Did you try to clone and run the repo?

patilkrunal commented 3 years ago

I dont actually remember I cloned or directly downloaded. Whats the difference bw these two. any advantages by cloning?

pratiksinghchauhan commented 3 years ago

No that is the same thing in this context I mean that won't cause this issue. I am not sure why this issue is caused, Did you check you entered the correct domain name in the Google developers website?

patilkrunal commented 3 years ago

I guess there might be some issues of cors. I'll try that again by following your blog. If the same issue crops up ill share whole code details and also full error details.

farshi commented 3 years ago

I have the same problem , react running on localhost:3000 and django localhost:8000 despite of CORS Allow header , the server reject the api call.

Screen Shot 2021-08-19 at 6 22 16 pm

in settings.py I have the below lines already and added crosheaders to INSTALLED_APPS and MIDDLEWARE
ALLOWED_HOSTS = []

CORS_ORIGIN_ALLOW_ALL = True

aag1992 commented 5 months ago

Had a similar problem when using react-google-drive-picker, when I run the UI on port 3000 everything runs smoothly. However when serving static files via port 8000 and django, the google picker popup gets blocked