Files
livedash-node/DEVELOPMENT.md
Kaj Kowalski bde0b44ea0 feat: Add authentication and session management with NextAuth.js and Prisma [broken]
- Implemented API session retrieval in `lib/api-auth.ts` to manage user sessions.
- Created authentication options in `lib/auth-options.ts` using NextAuth.js with credentials provider.
- Added migration scripts to create necessary tables for authentication in `migrations/0002_create_auth_tables.sql` and `prisma/migrations/20250601033219_add_nextauth_tables/migration.sql`.
- Configured ESLint with Next.js and TypeScript support in `eslint.config.mjs`.
- Updated Next.js configuration in `next.config.ts` for Cloudflare compatibility.
- Defined Cloudflare Worker configuration in `open-next.config.ts` and `wrangler.jsonc`.
- Enhanced type definitions for authentication in `types/auth.d.ts`.
- Created a Cloudflare Worker entry point in `src/index.ts.backup` to handle API requests and responses.
2025-06-01 16:34:54 +02:00

1.7 KiB

LiveDash-Node Development Guide

Simplified Development Setup

This project has been simplified to use ONE environment for local development to avoid confusion.

Quick Start

  1. Start Development Server

    pnpm run dev
    

    This starts Next.js on http://localhost:3000 with full authentication and dashboard.

  2. Login Credentials

    • Email: admin@example.com
    • Password: admin123

Development vs Production

  • Development: pnpm run dev - Next.js app using local D1 database
  • Production: Cloudflare Workers with remote D1 database

Environment Files

  • .env.local - Local development (Next.js)
  • .dev.vars - Cloudflare Workers development (only needed for pnpm run dev:cf)

Database

  • Local Development: Uses the same D1 database that Wrangler creates locally
  • Production: Uses remote Cloudflare D1 database

Key Commands

# Start development (recommended)
pnpm run dev

# Test Cloudflare Workers deployment locally (optional)
pnpm run dev:cf

# Deploy to production
pnpm run deploy

# Database migrations
pnpm run seedLocalD1    # Apply migrations to local D1
pnpm run predeploy      # Apply migrations to remote D1

Auth.js v5 Migration Complete

Migrated from NextAuth v4 to Auth.js v5
Updated all API routes and authentication flows
Configured for both development and production environments
Using Cloudflare D1 database with proper Auth.js v5 tables

Troubleshooting

  • If login doesn't work, ensure the local D1 database is set up: pnpm run seedLocalD1
  • If you see CSRF errors, try using Chrome instead of VS Code's browser
  • For any auth issues, check the console logs and verify environment variables