1
0
mirror of https://gitlab.com/2-chainz/2chainz.git synced 2025-06-15 17:36:39 +00:00
This commit is contained in:
Anson 2025-05-23 15:48:30 -06:00
parent 69238678b8
commit 6bb53f6f7d
2 changed files with 23 additions and 5 deletions

View File

@ -22,4 +22,5 @@ COPY . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-dev
CMD ["uv", "run", "fastapi", "run", "src/two_chainz", "--port", "80", "--proxy-headers"]
CMD ["uv", "run", "fastapi", "run", "src/two_chainz", "--port", "80", "--proxy-headers", "--forwarded-allow-ips", "*"]

View File

@ -3,17 +3,18 @@ import time
import tomllib
from datetime import datetime
from pathlib import Path
from fastapi import FastAPI
import logging
from fastapi import FastAPI, Request
from fastapi.middleware.trustedhost import TrustedHostMiddleware
from fastapi.staticfiles import StaticFiles
app = FastAPI()
app.add_middleware(
TrustedHostMiddleware,
allowed_hosts=["ansonbiggs.com", "*.ansonbiggs.com", "localhost"],
allowed_hosts=["*"],
)
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
start_time = time.time()
@ -30,6 +31,22 @@ def read_data() -> dict[str, str]:
data = read_data()
# Log all requests to debug issues
@app.middleware("http")
async def log_requests(request: Request, call_next):
# Log what's coming in
logger.info(f"Request: {request.method} {request.url.path}")
logger.info(f"Host header: {request.headers.get('host')}")
logger.info(f"CF-Ray: {request.headers.get('cf-ray', 'Not from Cloudflare')}")
try:
response = await call_next(request)
return response
except Exception as e:
logger.error(f"Request processing failed: {e}")
raise
@app.get("/api/")
async def ping():
return {