From b16c2b395dc866b97c1124b31505867bc3b0964c Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 7 Mar 2024 05:16:40 +0700 Subject: [PATCH] server host --- .env.template | 1 + src/shared/config.ts | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 .env.template create mode 100644 src/shared/config.ts diff --git a/.env.template b/.env.template new file mode 100644 index 0000000..e67dbc5 --- /dev/null +++ b/.env.template @@ -0,0 +1 @@ +VITE_SERVER_HOST # Required. Example api.website.com diff --git a/src/shared/config.ts b/src/shared/config.ts new file mode 100644 index 0000000..fa70517 --- /dev/null +++ b/src/shared/config.ts @@ -0,0 +1,6 @@ +import { getEnvVar } from "./lib/getEnvVar"; + +export const SERVER_HOST = getEnvVar("VITE_SERVER_HOST"); + +export const IS_SSL = window.location.protocol === "https:"; +export const API_HOST = `${IS_SSL ? "https://" : "http://"}${SERVER_HOST}/api`;