How to handle CORS for analytics super proxy?

153 views
Skip to first unread message

Anand Mani Sankar

unread,
Sep 9, 2014, 12:18:44 PM9/9/14
to google-analyti...@googlegroups.com
Hi,

I'm trying to make a call from my web app to the super proxy app that I have deployed in app engine. I realize that this is a cross origin request and would not go through. What is the approach to solve this problem and be able to get data from the super proxy app?

Thanks,
Anand

Sheldon Ketterer

unread,
Jan 2, 2015, 1:06:09 PM1/2/15
to google-analyti...@googlegroups.com
Hey, you may have solved this by now, but for future reference: 

You have to add a response header in the BaseHandler class (see base.py) with either a wildcard or specific domains you want to whitelist. You can do that with this:

self.response.headers.add_header('Access-Control-Allow-Origin', '*')

Then you can just send a GET request and parse the response.

Gregor Srdic

unread,
Mar 31, 2015, 9:46:30 AM3/31/15
to google-analyti...@googlegroups.com
Additionally, I had to add the following to get it working from Angular $resource (I guess it's required for ajax as well):

within class PublicQueryResponseHandler(base.BaseHandler):

  def options(self):      
       
self.response.headers['Access-Control-Allow-Origin'] = '*'
       
self.response.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
       
self.response.headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE'




Reply all
Reply to author
Forward
0 new messages