From ecdf3fef235c527a7b21f9596d59b11e2cc5c35d Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Tue, 21 Feb 2023 09:16:58 +0100 Subject: [PATCH] get api url from .env file --- .env.development | 1 + .env.production | 1 + .gitignore | 2 -- src/lib/api.ts | 7 +++---- 4 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 .env.development create mode 100644 .env.production diff --git a/.env.development b/.env.development new file mode 100644 index 000000000..e142b6be1 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +PUBLIC_API_BASE_URL=https://test.app.gitbutler.com/ diff --git a/.env.production b/.env.production new file mode 100644 index 000000000..ec4f10c86 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +PUBLIC_API_BASE_URL=https://app.gitbutler.com/ diff --git a/.gitignore b/.gitignore index 2cb18e5d5..5e1e3dbaf 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,4 @@ dist-ssr /build /.svelte-kit /package -.env -.env.* !.env.example diff --git a/src/lib/api.ts b/src/lib/api.ts index 104a56d82..1e1be00ab 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -1,8 +1,7 @@ -import { dev } from "$app/environment"; +import { PUBLIC_API_BASE_URL } from "$env/static/public"; +import * as log from "$lib/log"; -const apiUrl = dev - ? new URL("https://test.app.gitbutler.com/api/") - : new URL("https://app.gitbutler.com/api/"); +const apiUrl = new URL("/api/", new URL(PUBLIC_API_BASE_URL)); const getUrl = (path: string) => new URL(path, apiUrl).toString();