convert endpoint urls to env variables

This commit is contained in:
JBB0807 2025-05-02 17:20:38 -07:00
parent 28dd929927
commit 00c14f4eeb
4 changed files with 9 additions and 5 deletions

View file

@ -3,6 +3,8 @@ import "../scss/styles.scss";
import "../scss/components/_navbar.scss";
import { Link } from "react-router-dom";
const authUrl = import.meta.env.VITE_AUTH_URL;
const Navbar = () => {
const [glitchEffect, setGlitchEffect] = useState(false);
const [activeLink, setActiveLink] = useState("/");
@ -37,7 +39,7 @@ const Navbar = () => {
document.addEventListener("mousedown", handleClickOutside);
async function fetchUser() {
const res = await fetch("http://localhost:8080/auth/current_user", {
const res = await fetch(`${authUrl}/auth/current_user`, {
credentials: "include", // very important
});
if (res.ok) {

View file

@ -1,6 +1,8 @@
import React from "react";
import "@fortawesome/fontawesome-free/css/all.min.css";
const authUrl = import.meta.env.VITE_AUTH_URL;
function SignInForm() {
const [state, setState] = React.useState({
assignmentID: "",
@ -21,7 +23,7 @@ function SignInForm() {
console.log(`You are loggind in with email: ${assignmentId} and password: ${password}`);
console.log("Submitting login request with state:", state);
fetch("http://localhost:8080/auth/student/login", {
fetch(`${authUrl}/auth/student/login`, {
method: "POST",
headers: {
"Content-Type": "application/json",

View file

@ -34,7 +34,7 @@ function SignUpForm() {
const googleAuth = () => {
window.open(authUrl, "_self");
window.open(`${authUrl}/auth/google`, "_self");
};
return (