sign-in.tsx48 lines · main
| 1 | /* |
| 2 | * Studio sign-in page — Phase 5 of BACKEND_FORK_BRIEF.md (screen 1 of 8). |
| 3 | * |
| 4 | * Studio is a passive cookie consumer per BACKEND_FORK_PLAN.md §6. All auth |
| 5 | * surface lives on briven.tech. This page exists only to bounce the user to |
| 6 | * the control-plane sign-in flow with a `next=` return path back to Studio. |
| 7 | * |
| 8 | * Local-dev fallback (IS_PLATFORM=false): skip auth, go straight to the |
| 9 | * default project. Same behaviour as the upstream Studio for parity with |
| 10 | * `briven dev` workflows. |
| 11 | */ |
| 12 | |
| 13 | import type { GetServerSideProps } from 'next' |
| 14 | |
| 15 | import { IS_PLATFORM } from '@/lib/constants' |
| 16 | |
| 17 | const CONTROL_PLANE_ORIGIN = |
| 18 | process.env.NEXT_PUBLIC_BRIVEN_WEB_ORIGIN ?? 'https://briven.tech' |
| 19 | |
| 20 | export const getServerSideProps: GetServerSideProps = async ({ req, query }) => { |
| 21 | if (!IS_PLATFORM) { |
| 22 | return { |
| 23 | redirect: { destination: '/project/default', permanent: false }, |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | const host = req.headers.host ?? 'studio.briven.tech' |
| 28 | const proto = req.headers['x-forwarded-proto'] ?? 'https' |
| 29 | const next = |
| 30 | typeof query.next === 'string' && query.next.length > 0 |
| 31 | ? query.next |
| 32 | : `${proto}://${host}/` |
| 33 | |
| 34 | const url = new URL('/signin', CONTROL_PLANE_ORIGIN) |
| 35 | url.searchParams.set('next', next) |
| 36 | |
| 37 | return { |
| 38 | redirect: { destination: url.toString(), permanent: false }, |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | export default function SignInPage() { |
| 43 | return ( |
| 44 | <main className="flex min-h-dvh items-center justify-center bg-[var(--color-bg)] px-6 text-[var(--color-text)]"> |
| 45 | <p className="font-mono text-sm">redirecting to briven.tech to sign in…</p> |
| 46 | </main> |
| 47 | ) |
| 48 | } |