N
NPMChat

Menu

Tools

Theme

NPMChat v1.0

Built with Next.js & TypeScript

Environment Setup

To run NPMChat locally, follow these steps.

Prerequisites

  • Node.js (v18+)
  • MongoDB (Local or Atlas)
  • Cloudinary Account (for image uploads)

Backend Setup

  • Navigate to the backend/ directory.
  • Create a .env file based on .env.example:
PORT=8080

MONGODB_URI=your_mongodb_connection_string

JWT_SECRET=your_super_secret_key

CLOUDINARY_CLOUD_NAME=your_name

CLOUDINARY_API_KEY=your_key

CLOUDINARY_API_SECRET=your_secret

CLIENT_URL=http://localhost:3000

NODE_ENV=development

  • Install dependencies: npm install
  • Start development server: npm run dev

Frontend Setup

  • Navigate to the frontend/ directory.
  • Create a .env.local file:
NEXT_PUBLIC_API_URL=http://localhost:8080
  • Install dependencies: npm install
  • Start development server: npm run dev

Troubleshooting

  • CORS Issues: Ensure CLIENT_URL in the backend .env matches your frontend URL.
  • Socket Connection: If the socket fails to connect, verify that the backend is running on the expected port (default: 8080).
  • Image Uploads: If profile pictures fail to save, check your Cloudinary credentials.