Skip to content

Commit 929bea1

Browse files
committed
fix: update oauth endpoints for oauth-provider migration
- Fix end-session URL path (endsession → end-session) - Add error logging to token exchange for debugging - Remove debug logging from callback handler
1 parent fb3bd89 commit 929bea1

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/lib/auth.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ export async function exchangeCodeForTokens(
145145
}).toString(),
146146
});
147147

148-
if (!response.ok) return null;
148+
if (!response.ok) {
149+
const err = await response.text().catch(() => "");
150+
console.error(`[auth] exchangeCodeForTokens failed: ${response.status} ${err}`);
151+
return null;
152+
}
149153
return response.json();
150154
}
151155

@@ -165,7 +169,11 @@ export async function refreshAccessToken(refreshToken: string): Promise<{
165169
}).toString(),
166170
});
167171

168-
if (!response.ok) return null;
172+
if (!response.ok) {
173+
const err = await response.text().catch(() => "");
174+
console.error(`[auth] Token exchange failed: ${response.status} ${err}`);
175+
return null;
176+
}
169177
return response.json();
170178
}
171179

src/routes/_auth/logout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const getLogoutConfigFn = createServerFn({ method: "GET" }).handler(
88
const dashboardUrl = process.env.DASHBOARD_URL || "http://localhost:4000";
99
const clientId = process.env.DASHBOARD_CLIENT_ID || "dashboard";
1010
return {
11-
endSessionUrl: `${LANYARD_URL}/api/auth/oauth2/endsession?client_id=${encodeURIComponent(clientId)}&post_logout_redirect_uri=${encodeURIComponent(`${dashboardUrl}/login`)}`,
11+
endSessionUrl: `${LANYARD_URL}/api/auth/oauth2/end-session?client_id=${encodeURIComponent(clientId)}&post_logout_redirect_uri=${encodeURIComponent(`${dashboardUrl}/login`)}`,
1212
};
1313
},
1414
);

src/routes/api/auth/callback.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export const Route = createFileRoute("/api/auth/callback")({
2424
);
2525
}
2626

27+
console.log("[auth/callback] Exchanging code for tokens...");
2728
const tokens = await exchangeCodeForTokens(code, codeVerifier);
29+
console.log("[auth/callback] Tokens result:", tokens ? "success" : "null");
2830
if (!tokens) {
2931
return new Response(
3032
JSON.stringify({
@@ -67,7 +69,8 @@ export const Route = createFileRoute("/api/auth/callback")({
6769
"Set-Cookie": cookie,
6870
},
6971
});
70-
} catch {
72+
} catch (err) {
73+
console.error("[auth/callback] Error:", err);
7174
return new Response(
7275
JSON.stringify({ error: "Internal server error" }),
7376
{

0 commit comments

Comments
 (0)