iChat 是一款实时聊天应用程序,具有身份验证、用户配置文件(包括配置图片上传)和通过 WebSockets 进行消息传递等功能。
Real-time chat application with authentication, user profiles (including profile picture upload), and messaging over WebSockets.
/auth/check)frontend/ — React appbackend/ — Express + Socket.IO servercd backend
npm installcd frontend
npm installCreate .env files in both backend/ and frontend/.
backend/.envThe backend uses these variables (based on the code in backend/server.js, backend/config/db.js, backend/utils/generateToken.js, and backend/config/cloudinary.js):
# Server
PORT=3000
NODE_ENV=development
CLIENT_URL=http://localhost:5173
# Database
MONGODB_URI=mongodb+srv://:@
# Auth
JWT_SECRET=your_super_secret_jwt_key
# Cloudinary
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
# Email (if configured)
RESEND_API_KEY=your_resend_api_keyNotes:
MONGODB_URI is used like ${MONGODB_URI}/iChat in backend/config/db.js.httpOnly and will use:secure: true only in productionsameSite: "none" in production, "strict" in developmentfrontend/.envFrontend uses VITE_API_URL for non-development builds (see frontend/src/lib/axios.js).
VITE_API_URL=http://localhost:3000/In development mode, the frontend automatically uses http://localhost:3000/.
cd backend
npm run devBackend starts on http://localhost:3000 by default.
cd frontend
npm run devFrontend starts on http://localhost:5173 by default.
Base URL: http://localhost:3000
/auth)POST /auth/registerPOST /auth/loginPOST /auth/logoutGET /auth/check (requires auth cookie)PUT /auth/update-profile (requires auth cookie)/messages)GET /messages/contacts (requires auth cookie)GET /messages/chats (requires auth cookie)GET /messages/:id (requires auth cookie)POST /messages/send/:id (requires auth cookie)backend/utils/socket.js.jwt cookie (backend/middlewares/socketAuth.js).CLIENT_URL to your deployed frontend URL.credentials: truesameSite/secure must match your deployment (HTTPS required for sameSite=none).backend/package.json)npm run dev — start server with nodemonnpm start — start serverfrontend/package.json)npm run dev — start Vite dev servernpm run build — production buildnpm run preview — preview production buildnpm run lint — run ESLint暂无开放 Issues,或尚未同步最近议题。