Add CORS configuration

This commit is contained in:
Dita Aji Pratama 2024-12-29 14:16:19 +07:00
parent 02096d66a4
commit 9a6df51d76
2 changed files with 8 additions and 1 deletions

View File

@ -11,7 +11,10 @@ session_opts = {
'session.auto': True
}
# cors
def enable_cors():
response.headers['Access-Control-Allow-Origin' ] = '*'
response.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'
response.headers['Access-Control-Allow-Headers'] = 'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token, Authorization'
# error page 403
# error page 404

View File

@ -16,6 +16,10 @@ from config import server
app = Bottle()
@app.hook('after_request')
def after_request():
server.enable_cors()
app.merge(handler.app)
app.merge(staticdir.app)