Works fine in local environment but when deployed to koyeb i get this issue and i cant understand why
following is my code and attached image of response in local development vs koyeb:
@app.get("/health", status_code=200)
async def health_check(
request: Request,
client=Depends(
get_http_client
),
x_info_access_token: str = Header(None),
):
# Initialize the status dictionary
statuses = {"server_version": SERVER_VERSION}
# Extract protocol, host, and port from request
protocol = request.url.scheme
host = request.url.hostname or "localhost"
port = request.url.port
# Adjust host for development
if env_is_dev and port:
host = f"{host}:{port}"
# Construct and test each endpoint
for method_name, endpoint in endpoints_to_test.items():
full_url = f"{protocol}://{host}{endpoint}"
try:
# Make the request to the endpoint
response = await client.get(full_url, headers=dict(request.headers))
json_data = response.json()
if response.is_success:
json_data.pop("result", None)
statuses[endpoint] = {
"status_code": response.status_code,
"json_data": json_data,
"url": full_url,
}
else:
statuses[endpoint] = {
"status_code": response.status_code,
"error": json_data,
"url": full_url,
}
except Exception as e:
statuses[endpoint] = {
"error": f"{method_name} is down: {str(e)}",
"url": full_url,
}
# Return the statuses as JSON
return ORJSONResponse(status_code=200, content=statuses)
if I hit those endpoints individually I get no problems either.