anderson-ufrj
commited on
Commit
·
39c13e4
1
Parent(s):
05ab472
fix: configure uvicorn to accept proxy headers for HuggingFace Spaces
Browse filesAdd forwarded_allow_ips='*' and proxy_headers=True to fix 'Invalid host header' error
app.py
CHANGED
|
@@ -644,4 +644,11 @@ async def cache_stats():
|
|
| 644 |
if __name__ == "__main__":
|
| 645 |
port = int(os.getenv("PORT", 7860))
|
| 646 |
logger.info(f"🚀 Starting Enhanced Cidadão.AI Backend on port {port}")
|
| 647 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 644 |
if __name__ == "__main__":
|
| 645 |
port = int(os.getenv("PORT", 7860))
|
| 646 |
logger.info(f"🚀 Starting Enhanced Cidadão.AI Backend on port {port}")
|
| 647 |
+
# Disable host header validation for HuggingFace Spaces
|
| 648 |
+
uvicorn.run(
|
| 649 |
+
app,
|
| 650 |
+
host="0.0.0.0",
|
| 651 |
+
port=port,
|
| 652 |
+
forwarded_allow_ips="*", # Allow all proxy IPs
|
| 653 |
+
proxy_headers=True # Trust proxy headers
|
| 654 |
+
)
|