Skip to content

Commit 4fdd43a

Browse files
flowcore-platformclaude
andcommitted
Fix auth dialog URL construction for subpath hosting
window.location.origin alone drops the /usable-excel/ subpath on GitHub Pages, causing the dialog to open at a 404 URL and the Keycloak redirect to point to the wrong origin. - use-auth.ts: derive basePath from window.location.pathname so the dialog URL includes the correct subpath in any hosting environment - auth-dialog.html: use window.location.pathname for REDIRECT_URI instead of hardcoded /auth-dialog.html, same reason Both fixes are dev/prod agnostic — work on localhost:3333 and GitHub Pages. Co-Authored-By: Claude (claude-sonnet-4-6) <noreply@anthropic.com>
1 parent b332dd0 commit 4fdd43a

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/taskpane/auth-dialog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ <h2 id="title">Signing in…</h2>
5656
var CLIENT_ID = 'mcp_oauth_client';
5757
var SCOPES = 'openid profile email offline_access';
5858
// Redirect back to this same page (handles both start and callback)
59-
var REDIRECT_URI = window.location.origin + '/auth-dialog.html';
59+
var REDIRECT_URI = window.location.origin + window.location.pathname;
6060

6161
/* ------------------------------------------------------------------ */
6262
/* Helpers */

src/taskpane/hooks/use-auth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ export function useAuth(): AuthResult {
161161
// -------------------------------------------------------------------------
162162

163163
const login = useCallback(() => {
164-
const dialogUrl = `${window.location.origin}/auth-dialog.html`;
164+
const basePath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
165+
const dialogUrl = `${window.location.origin}${basePath}auth-dialog.html`;
165166

166167
Office.context.ui.displayDialogAsync(
167168
dialogUrl,

0 commit comments

Comments
 (0)