diff --git a/app/zine/create/page.tsx b/app/zine/create/page.tsx index ab7a6f2..b217623 100644 --- a/app/zine/create/page.tsx +++ b/app/zine/create/page.tsx @@ -16,6 +16,22 @@ import { CheckCircle, } from "lucide-react"; +// Helper to get correct path based on subdomain +function useZinePath() { + const [isSubdomain, setIsSubdomain] = useState(false); + + useEffect(() => { + setIsSubdomain(window.location.hostname.startsWith("zine.")); + }, []); + + return (path: string) => { + if (isSubdomain) { + return path.replace(/^\/zine/, "") || "/"; + } + return path; + }; +} + interface PageOutline { pageNumber: number; type: string; @@ -46,6 +62,7 @@ const STEP_LABELS = { export default function CreatePage() { const router = useRouter(); + const getPath = useZinePath(); const [state, setState] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); @@ -58,7 +75,7 @@ export default function CreatePage() { useEffect(() => { const input = sessionStorage.getItem("zineInput"); if (!input) { - router.push("/zine"); + router.push(getPath("/zine")); return; } @@ -255,7 +272,7 @@ export default function CreatePage() { const copyShareLink = async () => { if (!state) return; - const shareUrl = `${window.location.origin}/zine/z/${state.id}`; + const shareUrl = `${window.location.origin}${getPath(`/zine/z/${state.id}`)}`; await navigator.clipboard.writeText(shareUrl); setCopied(true); setTimeout(() => setCopied(false), 2000); @@ -279,7 +296,7 @@ export default function CreatePage() {

Error

{error}