Skip to content

Commit 2906bd0

Browse files
kartsclaude
andauthored
Fix OAuth authentication error on initial page load (#213)
Modified GitHub middleware to only apply authentication to API routes. This allows users to access the login page without encountering "GitHub token is required" errors. - Skip authentication for non-API routes (/, /auth/*, static assets) - Preserve authentication requirements for all /api/* endpoints - Enable proper OAuth flow for new users Resolves the catch-22 where users couldn't authenticate because they couldn't access the authentication page. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]>
1 parent 82c0d8c commit 2906bd0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

server/middleware/github.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ import { authenticateAndGetGitHubHeaders } from '../modules/authentication';
33
type Scope = 'org' | 'team' | 'ent';
44

55
export default defineEventHandler(async (event) => {
6+
// Only apply authentication to API routes
7+
const url = event.node.req.url || '';
8+
9+
// Skip authentication for non-API routes
10+
if (!url.startsWith('/api/')) {
11+
return;
12+
}
13+
614
// get runtime config
715
const config = useRuntimeConfig(event);
816

0 commit comments

Comments
 (0)