fix: add required headers (#8)

* fix: add required headers

* ci: remove compose linter
This commit is contained in:
Alexandre Teles (afterSt0rm) 2023-07-12 20:56:48 -03:00 committed by GitHub
parent 4fde994292
commit f4c10dc064
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -16,10 +16,6 @@ repos:
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/iamthefij/docker-pre-commit
rev: v3.0.1
hooks:
- id: docker-compose-check
- repo: https://github.com/pryorda/dockerfilelint-precommit-hooks
rev: v0.1.0
hooks:

12
app.py
View File

@ -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:;"