auth flow
This commit is contained in:
parent
9099af78d7
commit
3b81ad058a
@ -54,13 +54,13 @@ export default async function SectionPage(props: { params: { section: string } }
|
||||
notFound();
|
||||
}
|
||||
|
||||
// Create the proxy URL instead of direct iframe URL
|
||||
const proxyUrl = `/api/proxy/${section}`;
|
||||
// Get the direct URL for this section
|
||||
const directUrl = menuItems[section];
|
||||
|
||||
return (
|
||||
<div className="w-full h-[calc(100vh-8rem)]">
|
||||
<ResponsiveIframe
|
||||
src={proxyUrl}
|
||||
src={directUrl}
|
||||
className="w-full h-full border-none"
|
||||
allowFullScreen={true}
|
||||
/>
|
||||
|
||||
@ -10,11 +10,14 @@ export default async function ArtlabPage() {
|
||||
redirect("/signin");
|
||||
}
|
||||
|
||||
// Get the direct URL from environment variable
|
||||
const iframeUrl = process.env.NEXT_PUBLIC_IFRAME_DESIGN_URL || '';
|
||||
|
||||
return (
|
||||
<main className="w-full h-screen bg-black">
|
||||
<div className="w-full h-full px-4 pt-12 pb-4">
|
||||
<ResponsiveIframe
|
||||
src={process.env.NEXT_PUBLIC_IFRAME_DESIGN_URL || ''}
|
||||
src={iframeUrl}
|
||||
allowFullScreen={true}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -15,6 +15,21 @@ export interface ResponsiveIframeProps {
|
||||
heightOffset?: number;
|
||||
}
|
||||
|
||||
// Map of service prefixes to their base URLs - keep in sync with proxy route.ts
|
||||
const SERVICE_URLS: Record<string, string> = {
|
||||
'parole': process.env.NEXT_PUBLIC_IFRAME_PAROLE_URL || '',
|
||||
'alma': process.env.NEXT_PUBLIC_IFRAME_AI_ASSISTANT_URL || '',
|
||||
'crm': process.env.NEXT_PUBLIC_IFRAME_MEDIATIONS_URL || '',
|
||||
'vision': process.env.NEXT_PUBLIC_IFRAME_CONFERENCE_URL || '',
|
||||
'showcase': process.env.NEXT_PUBLIC_IFRAME_SHOWCASE_URL || '',
|
||||
'agilite': process.env.NEXT_PUBLIC_IFRAME_AGILITY_URL || '',
|
||||
'dossiers': process.env.NEXT_PUBLIC_IFRAME_DRIVE_URL || '',
|
||||
'the-message': process.env.NEXT_PUBLIC_IFRAME_THEMESSAGE_URL || '',
|
||||
'qg': process.env.NEXT_PUBLIC_IFRAME_MISSIONVIEW_URL || '',
|
||||
'design': process.env.NEXT_PUBLIC_IFRAME_DESIGN_URL || '',
|
||||
'artlab': process.env.NEXT_PUBLIC_IFRAME_DESIGN_URL || ''
|
||||
};
|
||||
|
||||
export default function ResponsiveIframe({
|
||||
src,
|
||||
title = 'Embedded content',
|
||||
@ -34,8 +49,26 @@ export default function ResponsiveIframe({
|
||||
const silentAuthTimerRef = useRef<NodeJS.Timeout | null>(null);
|
||||
const { data: session } = useSession();
|
||||
|
||||
// Convert proxy URLs to direct URLs to avoid double proxying
|
||||
const processedSrc = (() => {
|
||||
if (src.startsWith('/api/proxy/')) {
|
||||
// Extract the service name and path
|
||||
const parts = src.replace('/api/proxy/', '').split('/');
|
||||
const serviceName = parts[0];
|
||||
const path = parts.slice(1).join('/');
|
||||
|
||||
// Look up the base URL for this service
|
||||
const baseUrl = SERVICE_URLS[serviceName];
|
||||
if (baseUrl) {
|
||||
console.log(`Converting proxy URL to direct URL: ${src} -> ${baseUrl}/${path}`);
|
||||
return `${baseUrl}/${path}`;
|
||||
}
|
||||
}
|
||||
return src;
|
||||
})();
|
||||
|
||||
// Append token to src if provided
|
||||
const fullSrc = token ? `${src}${src.includes('?') ? '&' : '?'}token=${token}` : src;
|
||||
const fullSrc = token ? `${processedSrc}${processedSrc.includes('?') ? '&' : '?'}token=${token}` : processedSrc;
|
||||
|
||||
// Handle silent authentication refresh
|
||||
useEffect(() => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user