Spaces:
Runtime error
Runtime error
Silicon Valley - Admin
commited on
Commit
路
42efabf
1
Parent(s):
3f3db0e
Refactor server.py to replace ProxyHeadersMiddleware with ProxyFix for improved proxy handling
Browse files- Updated server.py to import ProxyFix from werkzeug and applied it to manage proxy headers.
- Adjusted parameters for ProxyFix to enhance compatibility with multiple proxies.
- Streamlined middleware configuration for better clarity and maintainability.
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,7 +21,11 @@ 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 |
app.logger.setLevel(LOG_LEVEL)
|
26 |
|
27 |
# 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 werkzeug.middleware.proxy_fix import ProxyFix # Importar ProxyFix de werkzeug
|
15 |
|
16 |
# Configuraciones
|
17 |
TIMEOUT: int = 40
|
|
|
21 |
# Inicializaci贸n de la aplicaci贸n Quart
|
22 |
app = Quart(__name__)
|
23 |
QuartSchema(app)
|
24 |
+
|
25 |
+
# Aplicar ProxyFix para manejar encabezados de proxy
|
26 |
+
# Ajusta los par谩metros seg煤n la cantidad de proxies delante de tu aplicaci贸n
|
27 |
+
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_port=1, x_prefix=1)
|
28 |
+
|
29 |
app.logger.setLevel(LOG_LEVEL)
|
30 |
|
31 |
# Excepciones personalizadas
|