Skip to content

Commit 7c7c9ee

Browse files
fix/use-env-api-url
2 parents badb175 + a7637bb commit 7c7c9ee

12 files changed

Lines changed: 30 additions & 21 deletions

frontend/src/components/Home.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import '../App.css';
44
import { auth, provider } from '../Firebase';
55
import { signInWithPopup } from 'firebase/auth';
66

7+
const API_URL = process.env.VITE_API_URL || '';
78

89
const Home = () => {
910
const navigate = useNavigate();
@@ -16,7 +17,7 @@ const Home = () => {
1617
avatar: result.user.photoURL,
1718
};
1819

19-
const res = await fetch('/api/auth/login', {
20+
const res = await fetch(`${API_URL}/api/auth/login`, {
2021
method: 'POST',
2122
headers: { 'Content-Type': 'application/json' },
2223
body: JSON.stringify(userData),

frontend/src/components/Login.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { auth, provider } from '../Firebase';
44
import { signInWithPopup } from 'firebase/auth';
55
import '../App.css';
66

7+
const API_URL = process.env.VITE_API_URL || '';
8+
79
const Login = () => {
810
const navigate = useNavigate();
911
const handleMicrosoftLogin = async () => {
@@ -14,7 +16,7 @@ const Login = () => {
1416
email: result.user.email,
1517
avatar: result.user.photoURL,
1618
};
17-
const res = await fetch('/api/auth/login', {
19+
const res = await fetch(`${API_URL}/api/auth/login`, {
1820
method: 'POST',
1921
headers: { 'Content-Type': 'application/json' },
2022
body: JSON.stringify(userData),

frontend/src/services/classroomService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios';
22

3-
const API_BASE_URL = 'http://localhost:3000/api/rooms';
3+
const API_BASE_URL = `${process.env.VITE_API_URL || 'http://localhost:3000'}/api/rooms`;
44

55
// Configure axios defaults
66
const axiosInstance = axios.create({

frontend/src/services/constraintService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:3000';
1+
const API_URL = process.env.VITE_API_URL || 'http://localhost:3000';
22

33
export const constraintService = {
44
// Get all constraints

frontend/src/services/courseAssignmentService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios';
22

3-
const API_URL = 'http://localhost:3000/api/timetable';
3+
const API_URL = `${process.env.VITE_API_URL || 'http://localhost:3000'}/api/timetable`;
44

55
// Configure axios instance with credentials
66
const axiosInstance = axios.create({

frontend/src/services/courseService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios';
22

3-
const API_BASE_URL = 'http://localhost:3000/api/courses';
3+
const API_BASE_URL = `${process.env.VITE_API_URL || 'http://localhost:3000'}/api/courses`;
44

55
// Configure axios defaults
66
const axiosInstance = axios.create({

frontend/src/services/dashboardService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios';
22

3-
const API_BASE_URL = 'http://localhost:3000/api/dashboard';
3+
const API_BASE_URL = `${process.env.VITE_API_URL || 'http://localhost:3000'}/api/dashboard`;
44

55
// Configure axios defaults
66
const axiosInstance = axios.create({

frontend/src/services/facultyService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios';
22

3-
const API_BASE_URL = 'http://localhost:3000/api/faculty';
3+
const API_BASE_URL = `${process.env.VITE_API_URL || 'http://localhost:3000'}/api/faculty`;
44

55
// Configure axios defaults
66
const axiosInstance = axios.create({

frontend/src/services/generatorService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios';
22

3-
const API_URL = 'http://localhost:3000/api/generator';
3+
const API_URL = `${process.env.VITE_API_URL || 'http://localhost:3000'}/api/generator`;
44

55
// Validate a timetable against constraints
66
export const validateTimetable = async (courseAssignmentId) => {

frontend/src/services/leaveRequestService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axios from 'axios';
22

3-
const API_URL = 'http://localhost:3000/api/leave-requests';
3+
const API_URL = `${process.env.VITE_API_URL || 'http://localhost:3000'}/api/leave-requests`;
44

55
// Create a new leave request
66
export const createLeaveRequest = async (leaveData) => {

0 commit comments

Comments
 (0)