diff --git a/bin/chat-fastapi.py b/bin/chat-fastapi.py index b10696d..29a74e0 100644 --- a/bin/chat-fastapi.py +++ b/bin/chat-fastapi.py @@ -33,6 +33,8 @@ """ ) +HEADER_DONT_CACHE = {"Cache-Control": "no-store"} + def make_signature(value: str) -> str: if CLOUDFLARE_SECRET_KEY is None: @@ -82,8 +84,10 @@ async def verify_captcha_middleware(request: Request, call_next): host = request.headers.get("referer") if host and host.startswith("http:"): - url = request.url.replace(scheme="https") - return RedirectResponse(url=str(url)) + error_html = ERROR_PAGE_TEMPLATE.substitute( + error_title="HTTPS is required for accessing this site", + ) + return Response(content=error_html, status_code=400, media_type="text/html") # Check if the user has completed the CAPTCHA verification captcha_verified = request.cookies.get("captcha_verified") @@ -109,17 +113,13 @@ async def captcha_page():