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 (
    <main className="w-full h-screen bg-black">
      <div className="w-full h-full px-4 pt-12 pb-4">
        <ResponsiveIframe 
          src={finalUrl}
          allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
        />
      </div>
    </main>
  );
} 