This project now serves both the frontend and backend from a single Node.js server, eliminating the need to run separate servers.
-
Install dependencies:
npm install
-
Start the server:
node server.js
-
Access the application:
- Frontend: http://localhost:3000/
- API: http://localhost:3000/api/*
├── server.js # Main server file (serves both frontend & API)
├── FiaibnbDemo/ # Frontend files
│ ├── index.html # Home page
│ ├── packages.html # Travel packages
│ ├── cart.html # Shopping cart
│ ├── history.html # Booking history
│ ├── signin.html # User sign in
│ ├── register.html # User registration
│ └── assets/ # CSS, JS, images
├── node_modules/ # Dependencies
└── package.json # Project configuration
- Home:
/→index.html - Packages:
/packages→packages.html - Cart:
/cart→cart.html - History:
/history→history.html - Sign In:
/signin→signin.html - Register:
/register→register.html
- GET
/api/bookings- Fetch user bookings - POST
/api/bookings- Create new booking - DELETE
/api/bookings/:id- Cancel booking - POST
/api/login- User login - POST
/api/register- User registration - GET
/api/data- Fetch all data - POST
/generate-token- Generate DevRev token
- Static File Serving: The server serves all frontend files (HTML, CSS, JS) from the
FiaibnbDemodirectory - API Routes: All API endpoints are prefixed with
/api/ - Frontend Routing: Any non-API route serves the main
index.htmlfile, enabling client-side routing - Integrated: No need for CORS issues or separate servers - everything runs on port 3000
- User Authentication: Login/Registration system
- Travel Packages: Browse and book travel packages
- Shopping Cart: Add packages to cart
- Booking History: View and manage past bookings
- Responsive Design: Works on all device sizes
- MongoDB Integration: Persistent data storage
- Frontend: HTML, CSS, JavaScript (vanilla)
- Backend: Node.js, Express.js
- Database: MongoDB
- Authentication: bcrypt for password hashing
- All frontend JavaScript files now use relative URLs (e.g.,
/api/bookingsinstead ofhttp://localhost:3000/api/bookings) - The server automatically handles MIME types for different file types
- Frontend routing is handled by the catch-all route that serves
index.html - API routes are protected from serving HTML files
- Port already in use: Change the port in
server.jsor kill the process using port 3000 - Files not loading: Ensure the
FiaibnbDemodirectory exists and contains all frontend files - API errors: Check the console logs for detailed error information
- MongoDB connection: Ensure MongoDB is running and the connection string is correct
The server provides comprehensive logging:
- 📄 Frontend file serving
- 📊 API requests and responses
- ✅ Successful operations
- ❌ Errors and failures
- 🔐 Authentication attempts
Run node server.js and watch the console for real-time information about what's happening on your server!
- CSS loading issue fixed for Vercel deployment
- Static file routing configured with vercel.json
- Build scripts updated for Vercel compatibility
- Files moved to public directory for proper Vercel deployment