Skip to content

Commit

Permalink
fix: correct authentication logic to be optional when no secret set
Browse files Browse the repository at this point in the history
Co-Authored-By: Han Xiao <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and hanxiao committed Feb 9, 2025
1 parent f1e41e7 commit 1d8999f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ interface QueryRequest extends Request {
// OpenAI-compatible chat completions endpoint
app.post('/v1/chat/completions', (async (req: Request, res: Response) => {
// Check authentication only if secret is set
if (secret) {
const authHeader = req.headers.authorization;
if (!authHeader || !authHeader.startsWith('Bearer ') || authHeader.split(' ')[1] !== secret) {
console.log('[chat/completions] Unauthorized request');
res.status(401).json({ error: 'Unauthorized' });
return;
}
const authHeader = req.headers.authorization;
if (secret && (!authHeader || !authHeader.startsWith('Bearer ') || authHeader.split(' ')[1] !== secret)) {
console.log('[chat/completions] Unauthorized request');
res.status(401).json({ error: 'Unauthorized' });
return;
}

// Log request details (excluding sensitive data)
Expand Down

0 comments on commit 1d8999f

Please sign in to comment.