From b7416e33ea84c7939d00a89ebc6ee98cc85b028d Mon Sep 17 00:00:00 2001 From: alma Date: Fri, 2 May 2025 11:10:53 +0200 Subject: [PATCH] auth flow --- .env.local | 1 + app/[section]/page.tsx | 4 ++-- app/api/proxy/[...path]/route.ts | 3 ++- app/design/page.tsx | 30 ++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 .env.local create mode 100644 app/design/page.tsx diff --git a/.env.local b/.env.local new file mode 100644 index 00000000..a46f0db2 --- /dev/null +++ b/.env.local @@ -0,0 +1 @@ +NEXT_PUBLIC_IFRAME_DESIGN_URL=https://design.slm-lab.net diff --git a/app/[section]/page.tsx b/app/[section]/page.tsx index 2dc1195e..b81a529e 100644 --- a/app/[section]/page.tsx +++ b/app/[section]/page.tsx @@ -15,11 +15,11 @@ const menuItems: Record = { 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 || '', - // Keep any existing custom ones + // Keep any existing custom ones, but use environment variables when available board: "https://example.com/board", chapter: "https://example.com/chapter", flow: "https://example.com/flow", - design: "https://example.com/design", + design: process.env.NEXT_PUBLIC_IFRAME_DESIGN_URL || "https://example.com/design", gitlab: "https://gitlab.com", missions: "https://example.com/missions" } diff --git a/app/api/proxy/[...path]/route.ts b/app/api/proxy/[...path]/route.ts index 9dadb016..e0d83a77 100644 --- a/app/api/proxy/[...path]/route.ts +++ b/app/api/proxy/[...path]/route.ts @@ -12,7 +12,8 @@ const SERVICE_URLS: Record = { '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 || '' + 'qg': process.env.NEXT_PUBLIC_IFRAME_MISSIONVIEW_URL || '', + 'design': process.env.NEXT_PUBLIC_IFRAME_DESIGN_URL || 'https://example.com/design' }; // Check if a service is Rocket.Chat (they require special authentication) diff --git a/app/design/page.tsx b/app/design/page.tsx new file mode 100644 index 00000000..336113d2 --- /dev/null +++ b/app/design/page.tsx @@ -0,0 +1,30 @@ +import { getServerSession } from "next-auth/next"; +import { authOptions } from "@/app/api/auth/[...nextauth]/route"; +import { redirect } from "next/navigation"; +import { ResponsiveIframe } from "@/app/components/responsive-iframe"; + +export default async function DesignPage() { + const session = await getServerSession(authOptions); + + if (!session) { + redirect("/signin"); + } + + // Use environment variable directly or via proxy + const designUrl = process.env.NEXT_PUBLIC_IFRAME_DESIGN_URL || ''; + + // Choose between direct URL or proxy - uncomment the one you want to use + // const finalUrl = designUrl; // Direct URL + const finalUrl = `/api/proxy/design`; // Proxy URL + + return ( +
+
+ +
+
+ ); +} \ No newline at end of file