Skip to content

Latest commit

Β 

History

History
128 lines (98 loc) Β· 3.79 KB

File metadata and controls

128 lines (98 loc) Β· 3.79 KB

πŸš€ OffCampusRooms Setup Instructions

πŸ”§ Current Issues Fixed

βœ… FiNavigation icon error - Replaced with FiMap
βœ… API configuration - Fixed undefined API base URL
βœ… Google Maps integration - Added proper error handling

πŸ“‹ What You Need to Do

1. Set Google Maps API Key

Option A: Create .env file (Recommended)

  1. In your FrontEnd/ directory, create a file called .env
  2. Add this line:
    VITE_GOOGLE_MAPS_API_KEY=your_actual_google_maps_api_key_here

Option B: Edit the config file directly

  1. Open FrontEnd/src/config/env.js
  2. Replace 'YOUR_GOOGLE_MAPS_API_KEY_HERE' with your actual API key

2. Get Google Maps API Key

  1. Go to Google Cloud Console
  2. Create a new project or select existing one
  3. Enable these APIs:
    • Google Maps JavaScript API
    • Distance Matrix API
    • Geocoding API
  4. Create an API key in "Credentials"
  5. Restrict the key to your domains:
    • http://localhost:3000/*
    • http://localhost:5173/*
    • https://off-campus-rooms.vercel.app/*

3. Set Backend API Key

  1. In your BackEnd/ directory, create a file called .env
  2. Add this line:
    GOOGLE_API_KEY=your_actual_google_maps_api_key_here

🚨 IMPORTANT: Replace Placeholder Values

In FrontEnd/src/config/env.js:

// Change this line:
export const GOOGLE_MAPS_API_KEY = 'YOUR_GOOGLE_MAPS_API_KEY_HERE';

// To your actual key:
export const GOOGLE_MAPS_API_KEY = 'AIzaSyC...'; // Your actual key here

πŸ” Testing the Fix

  1. Check browser console - You should see:

    API Configuration: {
      API_BASE_URL: "https://offcampusrooms.onrender.com",
      VITE_API_BASE_URL: "your_key_here",
      hostname: "off-campus-rooms.vercel.app"
    }
    
  2. Test FAQ creation - Should work without 405 errors

  3. Test driver creation - Should work without 405 errors

  4. Test Google Maps - Should load without InvalidKeyMapError

πŸ› If You Still Get Errors

405 Method Not Allowed

  • Check that your backend is running
  • Verify the API base URL is correct
  • Check that the backend routes are properly configured

Google Maps InvalidKeyMapError

  • Verify your API key is correct
  • Check that the APIs are enabled in Google Cloud Console
  • Verify domain restrictions are set correctly

FiNavigation Error

  • This should be fixed now
  • If you still see it, clear your browser cache and reload

πŸ“ File Structure After Fix

FrontEnd/
β”œβ”€β”€ .env                          ← Create this with VITE_GOOGLE_MAPS_API_KEY
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ api.js               ← Fixed API configuration
β”‚   β”‚   └── env.js               ← New environment config
β”‚   └── pages/
β”‚       └── StudentDashboard.jsx ← Fixed icon imports

BackEnd/
β”œβ”€β”€ .env                         ← Create this with GOOGLE_API_KEY
└── server.js                    ← Already fixed

🎯 Quick Test Commands

  1. Frontend: Check if API config loads correctly
  2. Backend: Test if Google Maps API key is loaded
  3. Maps: Try to load a page with Google Maps
  4. Admin: Try to create a FAQ or driver

πŸ“ž Need Help?

  1. Check the browser console for error messages
  2. Verify all environment variables are set
  3. Check that your Google Cloud project has billing enabled
  4. Ensure the APIs are enabled and the key is restricted properly

πŸš€ After Setup

Once everything is working:

  • βœ… FAQ creation will work
  • βœ… Driver management will work
  • βœ… Google Maps will load properly
  • βœ… Student dashboard will work without errors
  • βœ… All API calls will use the correct base URL

Remember: Never commit your actual API keys to version control!