Skip to content

Commit d62c44b

Browse files
committed
fix: improve env setup and prevent undefined auth API URL
- Add frontend and backend .env.example files - Document required environment variables - Add fallback for VITE_BACKEND_URL in auth pages - Prevent malformed undefined/api/auth/... requests
1 parent 9d34c19 commit d62c44b

4 files changed

Lines changed: 16 additions & 2 deletions

File tree

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Backend API URL
2+
# Local development
3+
VITE_BACKEND_URL=http://localhost:5000
4+
5+
# Production example
6+
# VITE_BACKEND_URL=https://your-backend-url.onrender.com

backend/.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# MongoDB connection string
2+
MONGO_URI=mongodb://localhost:27017/github_tracker
3+
4+
# Session secret - use a strong random string
5+
SESSION_SECRET=your_session_secret_here
6+
7+
# Server port
8+
PORT=5000

src/pages/Login/Login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useNavigate, Link } from "react-router-dom";
44
import { ThemeContext } from "../../context/ThemeContext";
55
import type { ThemeContextType } from "../../context/ThemeContext";
66

7-
const backendUrl = import.meta.env.VITE_BACKEND_URL;
7+
const backendUrl = import.meta.env.VITE_BACKEND_URL || '';
88

99
interface LoginFormData {
1010
email: string;

src/pages/Signup/Signup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { User, Mail, Lock, Eye, EyeOff } from "lucide-react";
66
import { ThemeContext } from "../../context/ThemeContext";
77
import type { ThemeContextType } from "../../context/ThemeContext";
88

9-
const backendUrl = import.meta.env.VITE_BACKEND_URL;
9+
const backendUrl = import.meta.env.VITE_BACKEND_URL || '';
1010

1111
interface SignUpFormData {
1212
username: string;

0 commit comments

Comments
 (0)