Skip to content

Commit 8515f98

Browse files
committed
feat: add multi-domain OAuth callback handling
Support multi-domain OAuth flow with core backend: - Update login link to pass callback URL parameter - Handle /github-callback responses in proxy (set cookie + redirect) - Use dynamic callback URL based on current domain
1 parent 127517d commit 8515f98

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

public/index.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,21 @@
6969
<div class="login">
7070
<p>
7171
Login with
72-
<a href="/api/login">
72+
<a id="login-link" href="/api/login">
7373
<img
7474
src="/images/GitHub-Mark-120px-plus.png"
7575
alt="GitHub logo linked to login"
7676
width="30"
7777
/></a>
7878
</p>
7979
</div>
80+
<script>
81+
// Set callback URL for multi-domain OAuth
82+
const loginLink = document.getElementById('login-link');
83+
const callbackUrl = window.location.origin + '/api/github-callback';
84+
const redirectUrl = '/dashboard';
85+
loginLink.href = `/api/login?callback=${encodeURIComponent(callbackUrl)}&redirect=${encodeURIComponent(redirectUrl)}`;
86+
</script>
8087
<div class="logo">
8188
<a href="/">
8289
<img src="/images/logo_world_driven.svg" alt="World driven logo"

server/proxy.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ async function handleProxy(req, res, next) {
7979
});
8080

8181
// Handle auth callback - set httpOnly cookie
82-
if (req.url === '/auth/callback' && response.ok) {
82+
// Supports both /auth/callback (API flow) and /github-callback (redirect flow)
83+
if (
84+
(req.url === '/auth/callback' || req.url.startsWith('/github-callback')) &&
85+
response.ok
86+
) {
8387
const data = await response.json();
8488
if (data.sessionId) {
8589
res.cookie('sessionId', data.sessionId, {
@@ -90,6 +94,11 @@ async function handleProxy(req, res, next) {
9094
});
9195
delete data.sessionId;
9296
}
97+
// For github-callback, redirect to the specified URL
98+
if (req.url.startsWith('/github-callback') && data.redirect) {
99+
res.redirect(data.redirect);
100+
return;
101+
}
93102
res.status(response.status).json(data);
94103
return;
95104
}

0 commit comments

Comments
 (0)