Skip to main content

auth-client

Next.js authentication pages deployed on Cloudflare via OpenNext. Handles sign-up, sign-in, password reset, and the multi-step onboarding flow. Sets the session cookie on .crowai.dev for cross-subdomain authentication.

Worker name: crow-auth-client Domain (prod): auth.crowai.dev Domain (dev): dev.auth.crowai.dev

Technology

  • Framework: Next.js (React) with App Router
  • Deployment: OpenNext on Cloudflare Workers
  • Styling: Tailwind CSS

Environment Variables

VariableExample
ENVIRONMENTdev
NEXT_PUBLIC_API_URLhttps://dev.api.crowai.dev
NEXT_PUBLIC_DASHBOARD_URLhttps://dev.app.crowai.dev
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYStripe publishable key for checkout

Key Pages

  • Sign Up -- Email/password registration with business email domain enforcement
  • Sign In -- Email/password and Google OAuth login
  • Forgot Password -- Password reset flow
  • Onboarding -- Multi-step wizard: organization setup, product source configuration, billing plan selection, team invitations

Authentication Flow

  1. User submits credentials on auth.crowai.dev
  2. Request goes to gateway api.crowai.dev, forwarded to auth service
  3. Better Auth creates a session and sets better-auth.session_token cookie on .crowai.dev
  4. User is redirected to app.crowai.dev (dashboard) where the cookie is automatically available

Onboarding Flow

The onboarding flow is a multi-step process orchestrated between the auth client and multiple backend services:

  1. Account creation -- Sign up with email/password
  2. Organization setup -- Create organization name and configure settings
  3. Product source -- Provide a website URL for product catalog crawling
  4. Billing -- Select a plan and complete Stripe checkout
  5. Team -- Invite team members (optional)
  6. Completion -- Redirect to dashboard

Dependencies

  • Outbound: gateway API (auth endpoints, onboarding endpoints)

Build and Deploy

cd auth-client
npx opennextjs-cloudflare build
npx wrangler deploy --env dev