AngularJS and CORS

51 views
Skip to first unread message

Charles Libicki

unread,
Mar 29, 2017, 8:48:52 AM3/29/17
to Google App Engine
I have a number of apps on GAE for Python and one based on AngularJS. The others are working fine, and the AngularJS one used to work OK. Now I get the following error:

XMLHttpRequest cannot load https://odorpatrol-toy.appspot.com/rest/loadlocale?locale=en. Redirect from 'https://odorpatrol-toy.appspot.com/rest/loadlocale?locale=en' to 'https://www.google.com/accounts/ServiceLogin?service=ah&passive=true&contin…wtdG95DBICYWgiFMpDF9nfp_N1BV6vlDLbk9fW6W52KAEyFCKyrQ1UB8dhlT02lpSU12eccFZu' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://odorpatrol-toy.appspot.com' is therefore not allowed access.

If I go to https://www.google.com/accounts/ServiceLogin explicitly from Chrome, the the app will work OK for a while. After a while (I assume when the login expires) the error crops up again. 

app.yaml has the following section:

- url: /rest/.*
script: main.APP
login: required
secure: always

but removing "secure: always" makes no difference.

The error occurs at the first client http request, but the Python server code for the request handler shows not sign of ever being 
accessed.

Thanks, for any help.

Attila-Mihaly Balazs

unread,
Apr 26, 2017, 5:33:57 AM4/26/17
to Google App Engine
You have "login: required" on your handler and whenever you're not logged in (or the login expired) you need to manually login again. The JS can not do the login for you in the background for multiple reasons (it doesn't know your password, google.com doesn't support CORS requests, etc).

Attila
Reply all
Reply to author
Forward
0 new messages