feat: Rename openrouter_key endpoint to openrouterkey for consistency
This commit is contained in:
parent
e720d14853
commit
fede9ae99e
@ -402,10 +402,10 @@ app = FastAPI(title="Unified API Service", lifespan=lifespan, debug=True)
|
||||
|
||||
@app.exception_handler(StarletteHTTPException)
|
||||
async def teapot_override(request: Request, exc: StarletteHTTPException):
|
||||
# Check if this is a request to the openrouter_key endpoint
|
||||
if request.url.path == "/openrouter_key" or request.url.path.endswith("/openrouter_key"):
|
||||
# Don't convert 404 errors for the openrouter_key endpoint to 418
|
||||
log.warning(f"Exception in openrouter_key endpoint: {exc.status_code} - {exc.detail}")
|
||||
# Check if this is a request to the openrouterkey endpoint
|
||||
if request.url.path == "/openrouterkey" or request.url.path.endswith("/openrouterkey"):
|
||||
# Don't convert 404 errors for the openrouterkey endpoint to 418
|
||||
log.warning(f"Exception in openrouterkey endpoint: {exc.status_code} - {exc.detail}")
|
||||
raise exc
|
||||
|
||||
# For all other 404 errors, return a teapot response
|
||||
@ -643,8 +643,8 @@ for route in app.routes:
|
||||
async def root():
|
||||
return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ", status_code=301)
|
||||
|
||||
@app.get("/openrouter_key", response_class=PlainTextResponse)
|
||||
async def openrouter_key(request: Request):
|
||||
@app.get("/openrouterkey", response_class=PlainTextResponse)
|
||||
async def openrouterkey(request: Request):
|
||||
"""private endpoint return openrouter api key"""
|
||||
# Basic security check
|
||||
auth_header = request.headers.get("Authorization")
|
||||
@ -664,8 +664,8 @@ async def openrouter_key(request: Request):
|
||||
return f"{settings.AI_API_KEY}"
|
||||
|
||||
# Add the same endpoint to the api_app to ensure it's accessible
|
||||
@api_app.get("/openrouter_key", response_class=PlainTextResponse)
|
||||
async def api_openrouter_key(request: Request):
|
||||
@api_app.get("/openrouterkey", response_class=PlainTextResponse)
|
||||
async def api_openrouterkey(request: Request):
|
||||
"""private endpoint return openrouter api key (api_app version)"""
|
||||
# Basic security check
|
||||
auth_header = request.headers.get("Authorization")
|
||||
@ -685,8 +685,8 @@ async def api_openrouter_key(request: Request):
|
||||
return f"{settings.AI_API_KEY}"
|
||||
|
||||
# Add the same endpoint to the discordapi_app to ensure it's accessible
|
||||
@discordapi_app.get("/openrouter_key", response_class=PlainTextResponse)
|
||||
async def discordapi_openrouter_key(request: Request):
|
||||
@discordapi_app.get("/openrouterkey", response_class=PlainTextResponse)
|
||||
async def discordapi_openrouterkey(request: Request):
|
||||
"""private endpoint return openrouter api key (discordapi_app version)"""
|
||||
# Basic security check
|
||||
auth_header = request.headers.get("Authorization")
|
||||
@ -724,7 +724,7 @@ async def agent(request: Request):
|
||||
@app.get("/debug-settings", response_class=PlainTextResponse)
|
||||
async def debug_settings(request: Request):
|
||||
"""Debug endpoint to check if settings are loaded correctly"""
|
||||
# Basic security check - only allow from localhost or with the same auth as openrouter_key
|
||||
# Basic security check - only allow from localhost or with the same auth as openrouterkey
|
||||
client_host = request.client.host
|
||||
auth_header = request.headers.get("Authorization")
|
||||
is_local = client_host == "127.0.0.1" or client_host == "::1" or client_host.startswith("172.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user