get api url from .env file

This commit is contained in:
Nikita Galaiko 2023-02-21 09:16:58 +01:00
parent 1d1c500c63
commit ecdf3fef23
No known key found for this signature in database
GPG Key ID: EBAB54E845BA519D
4 changed files with 5 additions and 6 deletions

1
.env.development Normal file
View File

@ -0,0 +1 @@
PUBLIC_API_BASE_URL=https://test.app.gitbutler.com/

1
.env.production Normal file
View File

@ -0,0 +1 @@
PUBLIC_API_BASE_URL=https://app.gitbutler.com/

2
.gitignore vendored
View File

@ -26,6 +26,4 @@ dist-ssr
/build /build
/.svelte-kit /.svelte-kit
/package /package
.env
.env.*
!.env.example !.env.example

View File

@ -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 const apiUrl = new URL("/api/", new URL(PUBLIC_API_BASE_URL));
? new URL("https://test.app.gitbutler.com/api/")
: new URL("https://app.gitbutler.com/api/");
const getUrl = (path: string) => new URL(path, apiUrl).toString(); const getUrl = (path: string) => new URL(path, apiUrl).toString();