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
| Variable | Example |
|---|---|
| ENVIRONMENT | dev |
| NEXT_PUBLIC_API_URL | https://dev.api.crowai.dev |
| NEXT_PUBLIC_DASHBOARD_URL | https://dev.app.crowai.dev |
| NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY | Stripe 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
- User submits credentials on
auth.crowai.dev - Request goes to gateway
api.crowai.dev, forwarded to auth service - Better Auth creates a session and sets
better-auth.session_tokencookie on.crowai.dev - 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:
- Account creation -- Sign up with email/password
- Organization setup -- Create organization name and configure settings
- Product source -- Provide a website URL for product catalog crawling
- Billing -- Select a plan and complete Stripe checkout
- Team -- Invite team members (optional)
- 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