mirror of
https://gitlab.com/2-chainz/2chainz.git
synced 2025-06-15 17:36:39 +00:00
try this
This commit is contained in:
parent
69238678b8
commit
6bb53f6f7d
@ -22,4 +22,5 @@ COPY . /app
|
|||||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||||
uv sync --locked --no-dev
|
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", "*"]
|
||||||
|
|
||||||
|
@ -3,17 +3,18 @@ import time
|
|||||||
import tomllib
|
import tomllib
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import logging
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI, Request
|
||||||
from fastapi.middleware.trustedhost import TrustedHostMiddleware
|
from fastapi.middleware.trustedhost import TrustedHostMiddleware
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
TrustedHostMiddleware,
|
TrustedHostMiddleware,
|
||||||
allowed_hosts=["ansonbiggs.com", "*.ansonbiggs.com", "localhost"],
|
allowed_hosts=["*"],
|
||||||
)
|
)
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
@ -30,6 +31,22 @@ def read_data() -> dict[str, str]:
|
|||||||
data = read_data()
|
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/")
|
@app.get("/api/")
|
||||||
async def ping():
|
async def ping():
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user