From eba4268718a4cc60c350132779b95d2baee952c0 Mon Sep 17 00:00:00 2001 From: John Costa Date: Sun, 13 Apr 2025 19:18:07 +0100 Subject: [PATCH] fix --- frontend/src/Login.tsx | 31 +++++++++++++++++-------------- frontend/src/network/index.ts | 8 ++++++-- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/frontend/src/Login.tsx b/frontend/src/Login.tsx index 344d8cd..25d3c46 100644 --- a/frontend/src/Login.tsx +++ b/frontend/src/Login.tsx @@ -1,7 +1,7 @@ import { Button } from "@kobalte/core/button"; import { TextField } from "@kobalte/core/text-field"; import { createSignal, Show, type Component } from "solid-js"; -import { postCode, postLogin } from "./network"; +import { base, postCode, postLogin } from "./network"; import { isTokenValid } from "./ProtectedRoute"; import { Navigate } from "@solidjs/router"; @@ -40,20 +40,23 @@ export const Login: Component = () => { const isAuthorized = isTokenValid(); return ( - }> -
- - Email - - - - - Code + <> + {base} + }> + + + Email - - - -
+ + + Code + + + + + +
+ ); }; diff --git a/frontend/src/network/index.ts b/frontend/src/network/index.ts index 067f3e7..f0d29c5 100644 --- a/frontend/src/network/index.ts +++ b/frontend/src/network/index.ts @@ -17,8 +17,12 @@ type BaseRequestParams = Partial<{ method: "GET" | "POST"; }>; +export const base = import.meta.env.DEV + ? "http://localhost:3040" + : "https://haystack.johncosta.tech"; + const getBaseRequest = ({ path, body, method }: BaseRequestParams): Request => { - return new Request(`http://localhost:3040/${path}`, { + return new Request(`${base}/${path}`, { body, method, }); @@ -29,7 +33,7 @@ const getBaseAuthorizedRequest = ({ body, method, }: BaseRequestParams): Request => { - return new Request(`http://localhost:3040/${path}`, { + return new Request(`${base}/${path}`, { headers: { Authorization: `Bearer ${localStorage.getItem("access")?.toString()}`, },