From 3e457de41617e02ebce95353f1068a869155b171 Mon Sep 17 00:00:00 2001 From: Nikolai R Kristiansen Date: Sun, 20 Feb 2022 01:25:55 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20VITE=5FAPI=5FURL=20referen?= =?UTF-8?q?ce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env-default | 1 + .gitignore | 1 + README.md | 1 + frontend/src/client.ts | 2 +- frontend/src/components/Header.tsx | 4 +--- 5 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 .env-default diff --git a/.env-default b/.env-default new file mode 100644 index 0000000..cd41370 --- /dev/null +++ b/.env-default @@ -0,0 +1 @@ +VITE_API_URL=http://localhost:3000 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 609f659..c9f4466 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ tmp/ frontend/dist static/modern .python-version +.env \ No newline at end of file diff --git a/README.md b/README.md index 256d60d..5513cdb 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ poetry shell pre-commit install python manage.py migrate bin/run +cp .env-default .env # in another terminal cd frontend diff --git a/frontend/src/client.ts b/frontend/src/client.ts index a3bfa2b..51ff67e 100644 --- a/frontend/src/client.ts +++ b/frontend/src/client.ts @@ -1,7 +1,7 @@ import { ApolloClient, InMemoryCache } from "@apollo/client"; const client = new ApolloClient({ - uri: import.meta.env.VITE_API_URL || "http://localhost:8000/graphql/", + uri: `${import.meta.env.VITE_API_URL}/graphql/`, cache: new InMemoryCache(), }); diff --git a/frontend/src/components/Header.tsx b/frontend/src/components/Header.tsx index f327e3a..99a857d 100644 --- a/frontend/src/components/Header.tsx +++ b/frontend/src/components/Header.tsx @@ -8,9 +8,7 @@ import { NavLink } from "react-router-dom"; import { ReactComponent as Logo } from "../assets/brick.svg"; import styles from "./Header.module.css"; -const ADMIN_URL = import.meta.env.VITE_API_URL - ? `${import.meta.env.VITE_API_URL}/admin` - : "http://localhost:8000/admin/"; +const ADMIN_URL = `${import.meta.env.VITE_API_URL}/admin`; const navLinkStyles = ({ isActive }: { isActive: boolean }) => (isActive ? "nav-link active" : "nav-link");