Skip to content

Commit

Permalink
fix: add required headers
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreteles committed Jul 12, 2023
1 parent 4fde994 commit ed8caba
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Check notice on line 43 in app.py

View workflow job for this annotation

GitHub Actions / qodana

Unused local symbols

Parameter 'request' value is not used

Check notice

Code scanning / QDPY

Unused local symbols Note

Parameter 'request' value is not used

Check notice on line 43 in app.py

View workflow job for this annotation

GitHub Actions / qodana

Unused local symbols

Parameter 'request' value is not used
response.headers["Cache-Control"] = "public, max-age=300"


@app.middleware("response")
async def add_csp(request, response):

Check notice on line 48 in app.py

View workflow job for this annotation

GitHub Actions / qodana

Unused local symbols

Parameter 'request' value is not used

Check notice

Code scanning / QDPY

Unused local symbols Note

Parameter 'request' value is not used

Check notice on line 48 in app.py

View workflow job for this annotation

GitHub Actions / qodana

Unused local symbols

Parameter 'request' value is not used
response.headers[
"Content-Security-Policy"
] = "default-src * 'unsafe-inline' 'unsafe-eval'; img-src * data:;"

0 comments on commit ed8caba

Please sign in to comment.