sign-in.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. import type { GetServerSideProps } from 'next'
  13. import { IS_PLATFORM } from '@/lib/constants'
  14. const CONTROL_PLANE_ORIGIN =
  15. process.env.NEXT_PUBLIC_BRIVEN_WEB_ORIGIN ?? 'https://briven.tech'
  16. export const getServerSideProps: GetServerSideProps = async ({ req, query }) => {
  17. if (!IS_PLATFORM) {
  18. return {
  19. redirect: { destination: '/project/default', permanent: false },
  20. }
  21. }
  22. const host = req.headers.host ?? 'studio.briven.tech'
  23. const proto = req.headers['x-forwarded-proto'] ?? 'https'
  24. const next =
  25. typeof query.next === 'string' && query.next.length > 0
  26. ? query.next
  27. : `${proto}://${host}/`
  28. const url = new URL('/signin', CONTROL_PLANE_ORIGIN)
  29. url.searchParams.set('next', next)
  30. return {
  31. redirect: { destination: url.toString(), permanent: false },
  32. }
  33. }
  34. export default function SignInPage() {
  35. return (
  36. <main className="flex min-h-dvh items-center justify-center bg-[var(--color-bg)] px-6 text-[var(--color-text)]">
  37. <p className="font-mono text-sm">redirecting to briven.tech to sign in…</p>
  38. </main>
  39. )
  40. }