In my GAE (Python) application, I implemented multilevel and multisite support based on the host part of the request object.
For example, www.foo.com/index.html and www.bar.com/index.html processed by the same application (for example, myapp.appspot.com ). The application reads the host value, and then decides which namespace and site configuration to use. This works fine while the application receives the request directly from the agent user.
However, I would like to use the channel API, but there is a problem because requests to /_ah/channel/connected/ and /_ah/channel/disconnected/ do not come from the original user agent. Instead, the request has Host: myapp.appspot.com and the to=myapp.appspot.com . (The from parameter is the token I expect. Also, www.foo.com/_ah/channel/jsapi redirected to the talkgadget server, which is not documented, but seems to be expected.)
I assume that the problem is caused by code in channel.js that my application does not call using the source host, for example. www.foo.com/_ah/channel/connected . Instead, it uses the talkgadget.google.com host, which (as far as I can tell) will call my application, but using myapp.appspot.com , ignoring the original host, and therefore I cannot use the host value for my purpose.
As a workaround, I can determine how to include host information in the channel token, so when my connected and disconnected handlers get the token, they can use the token instead.
However, I would like to know if there is a better approach where I could get the original hostname (e.g. www.foo.com ) for /_ah/channel/connected/ and /_ah/channel/disconnected/ . Any ideas?
This is what I have tried so far (without any success):
Adding a custom domain name to the JS src attribute:
<script type="text/javascript" src="//www.foo.com/_ah/channel/jsapi"></script>
I also tried manually overriding the base url of the channel socket suggested here: https://stackoverflow.com/questions/16558776/google-app-engine-channel-api-same-origin-policy
<script type="text/javascript"> onOpened = function() { </script>
I could not find the official documentation for channel.js, and I do not want to implement something that will break easily with the next Google update.