Skip to content

Allow API location to be configured using env #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Dependencies:
* Yarn v1.22.18+
* Go v1.19+

Copy `/client/.env.example` into `/client/.env.local`.

Shell 1:
```sh
cd server
Expand Down
4 changes: 3 additions & 1 deletion client/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ README.md
Dockerfile*
public
.svelte-kit
build
build
.env.example
.env.local
2 changes: 2 additions & 0 deletions client/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_API_ADDRESS="http://127.0.0.1:8090"
VITE_PUBLIC_API_ADDRESS="http://127.0.0.1:8090"
8 changes: 7 additions & 1 deletion client/src/lib/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,11 @@ export class Backend {
type ConnectBackend = () => Backend;

export const connectBackend: ConnectBackend = () => {
return new Backend('http://127.0.0.1:8090');
// Dynamic environment variables are temporarily broken on Windows.
// https://github.com/sveltejs/kit/issues/6361
return new Backend(
typeof window !== 'undefined'
? import.meta.env.VITE_PUBLIC_API_ADDRESS
: import.meta.env.VITE_API_ADDRESS
);
};