From ed8caba22a4bb7915db6e18022a4708ab7ff15e9 Mon Sep 17 00:00:00 2001 From: Alexandre Teles Date: Wed, 12 Jul 2023 20:33:37 -0300 Subject: [PATCH] fix: add required headers --- app.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app.py b/app.py index 9b1c312b..7f2a3294 100644 --- a/app.py +++ b/app.py @@ -37,3 +37,15 @@ def get_static_function(value): for src, dest in REDIRECTS.items(): app.route(src)(get_static_function(sanic.response.redirect(dest))) + + +@app.middleware("response") +async def add_cache_control(request, response): + response.headers["Cache-Control"] = "public, max-age=300" + + +@app.middleware("response") +async def add_csp(request, response): + response.headers[ + "Content-Security-Policy" + ] = "default-src * 'unsafe-inline' 'unsafe-eval'; img-src * data:;"