Configure MSAL redirect URI explicitly via environment variables

Added VITE_REDIRECT_URI and VITE_REDIRECT_URI_DEV environment variables to provide explicit control over Azure AD redirect URIs. Updated authConfig.js to use these variables with automatic environment detection (development vs production).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
michael 2025-11-18 09:27:13 -06:00
parent bd857ae015
commit 117a68a223
2 changed files with 15 additions and 2 deletions

View file

@ -27,3 +27,9 @@ VITE_BASE_PATH=/dashboard/
VITE_BACKEND_PORT=5001
VITE_AZURE_TENANT_ID=your-tenant-id-here
VITE_AZURE_CLIENT_ID=your-client-id-here
# Azure AD Redirect URIs
# Production redirect URI - must match what's registered in Azure AD
VITE_REDIRECT_URI=https://yourdomain.com/dashboard/
# Development redirect URI (used when running locally)
VITE_REDIRECT_URI_DEV=http://localhost:5173

View file

@ -4,12 +4,19 @@ import { LogLevel } from '@azure/msal-browser';
const tenantId = import.meta.env.VITE_AZURE_TENANT_ID || 'e519c2e6-bc6d-4fdf-8d9c-923c2f002385';
const clientId = import.meta.env.VITE_AZURE_CLIENT_ID || '014547f2-21c1-4245-881f-97f49543d963';
// Determine redirect URI based on environment
// In development, use VITE_REDIRECT_URI_DEV; in production, use VITE_REDIRECT_URI
const isDevelopment = import.meta.env.DEV;
const redirectUri = isDevelopment
? (import.meta.env.VITE_REDIRECT_URI_DEV || 'http://localhost:5173')
: (import.meta.env.VITE_REDIRECT_URI || window.location.origin);
export const msalConfig = {
auth: {
clientId: clientId,
authority: `https://login.microsoftonline.com/${tenantId}`,
redirectUri: window.location.origin,
postLogoutRedirectUri: window.location.origin,
redirectUri: redirectUri,
postLogoutRedirectUri: redirectUri,
navigateToLoginRequestUrl: false
},
cache: {