Spaces:
Runtime error
Runtime error
Silicon Valley - Admin
commited on
Commit
路
ed02a4f
1
Parent(s):
42efabf
Refactor server.py to replace ProxyFix with ProxyHeadersMiddleware for improved proxy handling
Browse files- Updated server.py to import ProxyHeadersMiddleware from Starlette and applied it to manage proxy headers.
- Adjusted middleware configuration for better clarity and maintainability, ensuring compatibility with ASGI applications.
server.py
CHANGED
@@ -11,7 +11,7 @@ from typing import Any, AsyncGenerator, Dict, Tuple, Union
|
|
11 |
|
12 |
from quart import Quart, websocket, request, send_from_directory
|
13 |
from quart_schema import QuartSchema, validate_request, validate_response
|
14 |
-
from
|
15 |
|
16 |
# Configuraciones
|
17 |
TIMEOUT: int = 40
|
@@ -21,11 +21,14 @@ TRUSTED_HOSTS: list[str] = ["127.0.0.1", "172.18.0.3"]
|
|
21 |
# Inicializaci贸n de la aplicaci贸n Quart
|
22 |
app = Quart(__name__)
|
23 |
QuartSchema(app)
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
29 |
app.logger.setLevel(LOG_LEVEL)
|
30 |
|
31 |
# Excepciones personalizadas
|
|
|
11 |
|
12 |
from quart import Quart, websocket, request, send_from_directory
|
13 |
from quart_schema import QuartSchema, validate_request, validate_response
|
14 |
+
from starlette.middleware.proxy_headers import ProxyHeadersMiddleware # Importar ProxyHeadersMiddleware de Starlette
|
15 |
|
16 |
# Configuraciones
|
17 |
TIMEOUT: int = 40
|
|
|
21 |
# Inicializaci贸n de la aplicaci贸n Quart
|
22 |
app = Quart(__name__)
|
23 |
QuartSchema(app)
|
24 |
+
app.asgi_app = ProxyHeadersMiddleware(
|
25 |
+
app.asgi_app,
|
26 |
+
x_for=1,
|
27 |
+
x_proto=1,
|
28 |
+
x_host=1,
|
29 |
+
x_port=1,
|
30 |
+
x_prefix=1
|
31 |
+
)
|
32 |
app.logger.setLevel(LOG_LEVEL)
|
33 |
|
34 |
# Excepciones personalizadas
|