Over the weekend chrome seems to have updated and now blocks my cross-domain requests:
I have one server, two domains, and a shared web icon font on one that needs to load on the other. I'd rather not force cherrypy to be aware of which domain it is serving (the mirror or the main one), because for that effort I might as well clone all the code.
My chrome console.log error message is:
Font from origin 'http://djotjog.com' has been blocked from loading by Cross-Origin Resource Sharing policy:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://storylearning.org' is therefore not allowed access.
In cherrypy I tried to enable this but the docs are sketchy. Here is what I tried:
class root:
def stest(self, **kw):
cherrypy.response.headers['Content-Type'] = 'text/html'
cherrypy.response.headers["Access-Control-Allow-Origin"] = "*"
html = some_function()
return html
def CORS():
cherrypy.response.headers["Access-Control-Allow-Origin"] = "*"
if __name__=="__main__":
cherrypy.tools.CORS = cherrypy.Tool('before_handler', CORS)
cherrypy.config.update({
'environment': 'production',
'log.screen': False,
'log.error_file':'cperror.log',
'server.socket_host': '127.0.0.1',
'server.socket_port': 15722,
'server.thread_pool': 2,
'server.thread_pool_max': 2
So what is the right way to handle cross-domain requests on cherrypy?