mirror of
https://github.com/karpathy/nanochat.git
synced 2026-05-07 16:30:11 +00:00
Remove NextAuth and replace with token-based auth against the backend
auth service (OAuth + JWT). The frontend now redirects login to
/api/auth/google and /api/auth/github (proxied by nginx to the auth
service), captures the JWT from the redirect query param, and uses it
for all API calls.
Key changes:
- Remove next-auth dependency and all NextAuth config/routes
- Add lib/auth-client.ts (JWT token storage + auth headers)
- Add hooks/useAuth.ts (client-side auth state + token capture)
- Rewrite middleware.ts to pass-through (client-side auth only)
- Login page uses plain <a> links to /api/auth/{provider}
- Chat page captures access_token from OAuth redirect
- Zustand store fetches conversations from real chat-api via JWT
- API routes proxy /api/conversations/* to chat-api with auth
- chat/stream route supports conversationId + auth header forwarding
- useSSE hook accepts auth headers for authenticated streaming
- Sidebar loads conversations from API, supports delete
- Landing page (Hero, LandingNav) uses useAuth instead of useSession
- Add .env.production.example and scripts/generate-jwt-keys.sh
Mock echo fallback preserved when CHAT_API_URL is not set.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
37 lines
889 B
JSON
37 lines
889 B
JSON
{
|
|
"name": "samosachaat-frontend",
|
|
"version": "0.1.0",
|
|
"private": true,
|
|
"scripts": {
|
|
"dev": "next dev -p 3000",
|
|
"build": "next build",
|
|
"start": "next start -p 3000",
|
|
"lint": "next lint",
|
|
"typecheck": "tsc --noEmit"
|
|
},
|
|
"dependencies": {
|
|
"clsx": "^2.1.1",
|
|
"framer-motion": "^11.11.8",
|
|
"highlight.js": "^11.10.0",
|
|
"lucide-react": "^0.451.0",
|
|
"next": "14.2.15",
|
|
"react": "^18.3.1",
|
|
"react-dom": "^18.3.1",
|
|
"react-markdown": "^9.0.1",
|
|
"rehype-highlight": "^7.0.0",
|
|
"remark-gfm": "^4.0.0",
|
|
"zustand": "^4.5.5"
|
|
},
|
|
"devDependencies": {
|
|
"@types/node": "^20.16.10",
|
|
"@types/react": "^18.3.11",
|
|
"@types/react-dom": "^18.3.0",
|
|
"autoprefixer": "^10.4.20",
|
|
"eslint": "^8.57.1",
|
|
"eslint-config-next": "14.2.15",
|
|
"postcss": "^8.4.47",
|
|
"tailwindcss": "^3.4.13",
|
|
"typescript": "^5.6.2"
|
|
}
|
|
}
|