Spaces:
Runtime error
Runtime error
Ko-TTS-Arena Contributors Claude Opus 4.5 commited on
Commit ·
c7fb090
1
Parent(s): 0d8b012
Add ProxyFix middleware to get real client IP
Browse filesHF Spaces uses reverse proxy, so X-Forwarded-For header
needs to be properly handled via ProxyFix middleware.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -62,6 +62,7 @@ from flask import (
|
|
| 62 |
session,
|
| 63 |
abort,
|
| 64 |
)
|
|
|
|
| 65 |
from flask_login import LoginManager, current_user
|
| 66 |
from models import *
|
| 67 |
from auth import auth, init_oauth, is_admin
|
|
@@ -131,6 +132,8 @@ if not IS_SPACES:
|
|
| 131 |
load_dotenv() # Only load .env if not running in a Hugging Face Space
|
| 132 |
|
| 133 |
app = Flask(__name__)
|
|
|
|
|
|
|
| 134 |
app.config["SECRET_KEY"] = os.getenv("SECRET_KEY", os.urandom(24))
|
| 135 |
|
| 136 |
# Configure database path - use persistent storage in HF Spaces
|
|
|
|
| 62 |
session,
|
| 63 |
abort,
|
| 64 |
)
|
| 65 |
+
from werkzeug.middleware.proxy_fix import ProxyFix
|
| 66 |
from flask_login import LoginManager, current_user
|
| 67 |
from models import *
|
| 68 |
from auth import auth, init_oauth, is_admin
|
|
|
|
| 132 |
load_dotenv() # Only load .env if not running in a Hugging Face Space
|
| 133 |
|
| 134 |
app = Flask(__name__)
|
| 135 |
+
# Apply ProxyFix to handle X-Forwarded-For headers from HF Spaces proxy
|
| 136 |
+
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1)
|
| 137 |
app.config["SECRET_KEY"] = os.getenv("SECRET_KEY", os.urandom(24))
|
| 138 |
|
| 139 |
# Configure database path - use persistent storage in HF Spaces
|