From f111ffc427a34819b1f414f0797487e5ed2b54e2 Mon Sep 17 00:00:00 2001 From: puke <1129090915@qq.com> Date: Sat, 6 Dec 2025 14:13:20 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E6=B7=BB=E5=8A=A0=E5=8F=8D=E5=90=91?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E5=8D=8F=E8=AE=AE=E5=A4=B4=E4=B8=AD=E9=97=B4?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=94=AF=E6=8C=81=20Nginx/Traefik=20?= =?UTF-8?q?=E5=90=8E=E6=AD=A3=E7=A1=AE=E8=AF=86=E5=88=AB=20HTTPS=20?= =?UTF-8?q?=E8=AF=B7=E6=B1=82"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c83e905c633c5c27f1001d9667c8d12fdf55690a. --- api/app.py | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/api/app.py b/api/app.py index afa9e3b..fa402ed 100644 --- a/api/app.py +++ b/api/app.py @@ -34,7 +34,7 @@ if str(_project_root) not in sys.path: import argparse from contextlib import asynccontextmanager -from fastapi import FastAPI, Request +from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from loguru import logger @@ -108,24 +108,6 @@ app = FastAPI( lifespan=lifespan, ) -# Add middleware for handling reverse proxy headers (Nginx/Traefik) -@app.middleware("http") -async def handle_forwarded_proto(request: Request, call_next): - """ - Handle X-Forwarded-Proto header from reverse proxy - - This ensures that request.base_url returns the correct protocol (https) - when the application is behind a reverse proxy like Nginx or Traefik. - """ - # Check for X-Forwarded-Proto header (standard) - forwarded_proto = request.headers.get("x-forwarded-proto") - if forwarded_proto: - # Update the request scheme - request.scope["scheme"] = forwarded_proto - - response = await call_next(request) - return response - # Add CORS middleware if api_config.cors_enabled: app.add_middleware(