This is a Next.js project bootstrapped with create-next-app.
The chat backend supports both OpenAI and Anthropic models.
Set these in .env.local:
# optional: force provider ("openai" | "anthropic")
AI_PROVIDER=openai
# optional: provider-agnostic model override (e.g. gpt-4.1-mini or claude-3-7-sonnet-latest)
AI_MODEL=
# OpenAI
OPENAI_API_KEY=
OPENAI_MODEL=gpt-4.1-mini
OPENAI_REASONING_SUMMARY=auto
OPENAI_REASONING_EFFORT=medium
# Anthropic
ANTHROPIC_API_KEY=
ANTHROPIC_MODEL=claude-3-7-sonnet-latestRouting behavior:
AI_PROVIDER=anthropicuses Anthropic.AI_PROVIDER=openaiuses OpenAI.- Without
AI_PROVIDER,claude-*models route to Anthropic; everything else routes to OpenAI.
Users receive daily credits with a non-accumulating reset to 30.
Run credits migration:
yarn db:migrate:creditsOptional admin allowlists (comma-separated) for manual refill access in Settings:
RNC_ADMIN_USER_IDS=
RNC_ADMIN_EMAILS=ShareDB server storage uses PostgreSQL.
Set in .env.local:
# Recommended: Neon Postgres URL
SHAREDB_DATABASE_URL=
# Optional fallback used when SHAREDB_DATABASE_URL is missing
DATABASE_URL=
# ShareDB websocket server port
SHAREDB_PORT=8080
# Optional: set to false for local non-SSL Postgres
SHAREDB_REQUIRE_SSL=trueRun ShareDB table migration:
yarn db:migrate:sharedbTrack document ownership (doc_id -> user_id) in Neon:
yarn db:migrate:documents
yarn db:migrate:document-sharesSafari can fail OAuth completion when auth cookies are set with SameSite=None; Partitioned, which can cause a sign-in loop (/auth/callback -> /doc -> /auth/sign-in).
To keep behavior stable across Safari/Chrome/Edge, this app normalizes Neon auth cookies at app boundaries (not in node_modules):
- Utility:
lib/auth/cookie-compat.ts - API boundary:
app/api/auth/[...path]/route.ts - Middleware boundary:
proxy.ts
Normalization rules (only for __Secure-neon-auth.* cookies):
- Remove
Partitioned - Rewrite
SameSite=NonetoSameSite=Lax - Preserve other attributes (
Secure,HttpOnly,Path,Domain,Max-Age, etc.)
Notes:
/auth/callbackremains simple (handles explicit OAuth error params; otherwise redirects toredirectTo)- OAuth verifier exchange remains middleware-driven
- No polling/retry logic and no SDK monkey patching
Quick validation:
# local
curl -i -X POST 'http://localhost:3000/api/auth/sign-in/social' \
-H 'content-type: application/json' \
--data '{"provider":"google","callbackURL":"/auth/callback?redirectTo=%2Fdoc","disableRedirect":true}'
# production
curl -i -X POST 'https://rowsncolumns.ai/api/auth/sign-in/social' \
-H 'content-type: application/json' \
-H 'origin: https://rowsncolumns.ai' \
--data '{"provider":"google","callbackURL":"/auth/callback?redirectTo=%2Fdoc","disableRedirect":true}'Expected Set-Cookie for Neon auth cookies:
- Contains
SameSite=Lax - Does not contain
Partitioned
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen https://localhost:3000 with your browser to see the result. OAuth sign-in (especially Safari) requires secure cookies, so dev now starts with HTTPS by default. Use https://localhost:3000.
If you need plain HTTP for debugging, run:
yarn dev:httpYou can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.