def loadCors(app):
    corsRoutes = ['/login', '/logout',
                  '/signature', '/signature/<token>',
                  '/run', 'run/<token>',
                  '/event/<token>',
                  '/fire', '/fire/<token>'
                  ]

    @app.hook('after_request')
    def enableCors():
        '''
        Add CORS headers to each response
        Don't use the wildcard '*' for Access-Control-Allow-Origin in production.
        '''
        #bottle.response.set_header('Access-Control-Allow-Credentials', 'true')
        bottle.response.set_header('Access-Control-Max-Age:', '3600')
        bottle.response.set_header('Access-Control-Allow-Origin', '*')
        bottle.response.set_header('Access-Control-Allow-Methods',
                            'PUT, GET, POST, DELETE, OPTIONS')
        bottle.response.set_header('Access-Control-Allow-Headers',
            'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token, X-Auth-Token')

    @app.route(corsRoutes, method='OPTIONS')
    def allowOption(path=None):
        '''
        Respond to OPTION request method
        '''
        return {}

    return app
Load support for CORS Cross Origin Resource Sharing
dataset/ETHPy150Open saltstack/halite/halite/server_bottle.py/loadCors