
- Explicitly configure docs_url and redoc_url in FastAPI app
- Add /debug endpoint to verify FastAPI is running correctly
- Enhance root endpoint with more helpful information
- Helps troubleshoot reverse proxy configuration issues
🤖 Generated with BackendIM
Co-Authored-By: Claude <noreply@anthropic.com>
80 lines
2.0 KiB
Python
80 lines
2.0 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.core.config import settings
|
|
from app.api.v1.router import api_router
|
|
from app.db.session import engine
|
|
from app.db.base import Base
|
|
|
|
# Create database tables
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title=settings.APP_NAME,
|
|
version=settings.APP_VERSION,
|
|
description="AI-Powered Resume & Job Match Hub - Helping job seekers find the perfect match",
|
|
openapi_url="/openapi.json",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc"
|
|
)
|
|
|
|
# Configure CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.CORS_ORIGINS,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include API routes
|
|
app.include_router(api_router, prefix="/api/v1")
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
"""Root endpoint providing service information"""
|
|
return {
|
|
"service": settings.APP_NAME,
|
|
"version": settings.APP_VERSION,
|
|
"description": "AI-Powered Resume & Job Match Hub",
|
|
"message": "FastAPI application is running successfully",
|
|
"endpoints": {
|
|
"documentation": "/docs",
|
|
"alternative_docs": "/redoc",
|
|
"openapi_schema": "/openapi.json",
|
|
"health_check": "/health",
|
|
"debug_info": "/debug",
|
|
"api_base": "/api/v1"
|
|
}
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
"""Health check endpoint"""
|
|
return {
|
|
"status": "healthy",
|
|
"service": settings.APP_NAME,
|
|
"version": settings.APP_VERSION
|
|
}
|
|
|
|
|
|
@app.get("/debug")
|
|
async def debug_info():
|
|
"""Debug endpoint to verify FastAPI is running"""
|
|
import os
|
|
return {
|
|
"message": "FastAPI application is running",
|
|
"service": settings.APP_NAME,
|
|
"version": settings.APP_VERSION,
|
|
"python_version": os.sys.version,
|
|
"available_endpoints": [
|
|
"/",
|
|
"/health",
|
|
"/debug",
|
|
"/docs",
|
|
"/redoc",
|
|
"/openapi.json",
|
|
"/api/v1/*"
|
|
]
|
|
} |