diff --git a/backend/src/server.ts b/backend/src/server.ts index ceb0323..ca52bd2 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -34,7 +34,7 @@ const INVALID_EXTS: string[] = ["exe", "dll", "obj", "lib", "bin", "dat", "pdf", * TODO: Update hosts for production */ const corsOptions: cors.CorsOptions = { - origin: ["http://localhost:3100", "https://192.168.1.211:3100"], + origin: ["http://localhost:3100", "http://192.168.1.211:3100"], methods: ["GET", "POST"] }; APP.use(cors()); @@ -71,6 +71,8 @@ v1.post("/login", (req: Request, res: Response): void => { // Get info from body const {username, password} = req.body; + console.log("I GOT HIT BABY!!!"); + // Get required info from the environment and validate // TODO: Make sure the ENV is sourced through docker compose! if (process.env["FILE_GOPHERNEST_USER"] === username && validateHash(password, process.env["FILE_GOPHERNEST_PASSWORD"] as string)) { diff --git a/frontend/src/components/LoginForm.jsx b/frontend/src/components/LoginForm.jsx index a227d6c..032c4f1 100644 --- a/frontend/src/components/LoginForm.jsx +++ b/frontend/src/components/LoginForm.jsx @@ -5,6 +5,12 @@ import RememberMe from "./RememberMe.jsx"; import {useNavigate} from "react-router-dom"; export default function LoginForm() { + /** + * URL To the backend web server + * @type {string} + */ + const backendUrl = "http://backend:5000"; + const [username, setUsername] = useState(""); const [remember, setRemember] = useState(false); const [password, setPassword] = useState(""); @@ -56,7 +62,7 @@ export default function LoginForm() { // TODO: There is no validation yet, need to implement that const sendAuthReq = async (username, password) => { - const resp = await fetch("http://localhost:5000/v1/login", { + const resp = await fetch(`${backendUrl}/v1/login`, { method: "POST", headers: { "Content-Type": "application/json", diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsx index 0c02455..cc3ba88 100644 --- a/frontend/src/pages/Dashboard.jsx +++ b/frontend/src/pages/Dashboard.jsx @@ -10,6 +10,12 @@ export default function Dashboard() { // Store the default path const defaultPath = ["home", "azpect", "Documents"]; + /** + * URL To the backend web server + * @type {string} + */ + const backendUrl = "http://backend:5000"; + const [token, setToken] = useState(null); const [path, setPath] = useState([...defaultPath]); const [showHidden, setShowHidden] = useState(false); @@ -40,7 +46,7 @@ export default function Dashboard() { useEffect(() => { const getData = async (token) => { - const response = await fetch(`http://localhost:5000/v1/children?path=/${path.join("/")}`, { + const response = await fetch(`${backendUrl}/v1/children?path=/${path.join("/")}`, { method: "GET", headers: { "Content-Type": "application/json", @@ -138,7 +144,7 @@ export default function Dashboard() { const download = async (paths) => { try { - const resp = await fetch("http://localhost:5000/v1/download", { + const resp = await fetch(`${backendUrl}/v1/download`, { method: "POST", headers: { "Content-Type": "application/json", @@ -193,7 +199,7 @@ export default function Dashboard() { const exitAndSaveFile = (newContent) => { const updateContent = async (path, content) => { - const resp = await fetch("http://localhost:5000/v1/update", { + const resp = await fetch(`${backendUrl}/v1/update`, { method: "POST", headers: { "Content-Type": "application/json", @@ -222,7 +228,7 @@ export default function Dashboard() { const [editingFileContent, setEditingFileContent] = useState(""); useEffect(() => { const fetchContent = async (path) => { - const resp = await fetch(`http://localhost:5000/v1/content?path=${path}`, { + const resp = await fetch(`${backendUrl}/v1/content?path=${path}`, { method: "GET", headers: { "Content-Type": "application/json",