diff --git a/app/[section]/page.tsx b/app/[section]/page.tsx index d24fe1c2..45b77a08 100644 --- a/app/[section]/page.tsx +++ b/app/[section]/page.tsx @@ -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 (
diff --git a/app/artlab/page.tsx b/app/artlab/page.tsx index 756df2cf..c6038914 100644 --- a/app/artlab/page.tsx +++ b/app/artlab/page.tsx @@ -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 (
diff --git a/app/components/responsive-iframe.tsx b/app/components/responsive-iframe.tsx index 42d6476b..936c9e22 100644 --- a/app/components/responsive-iframe.tsx +++ b/app/components/responsive-iframe.tsx @@ -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 = { + '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(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(() => {