Skip to content

Commit

Permalink
remove the need to specify backend port
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparkallas authored Oct 31, 2023
1 parent cf8c8ea commit 28663cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions apps/frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NEXT_PUBLIC_WALLECT_CONNECT_PROJECT_ID=952483bf7a0f5ace4c40eb53967f1368
BACKEND_PROTOCOL=http
BACKEND_HOST=localhost
BACKEND_PORT=3001
INTERNAL_API_KEY=my-secret-key
9 changes: 7 additions & 2 deletions apps/frontend/src/internalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ const internalConfig: InternalConfig = {
},
getBackendBaseUrl() {
const host = ensureDefined(process.env.BACKEND_HOST, 'BACKEND_HOST');
const port = Number(ensureDefined(process.env.BACKEND_PORT, 'BACKEND_PORT'));
return new URL(`http://${host}:${port}`);
const protocol = process.env.BACKEND_PROTOCOL ?? "https";
const port = Number(process.env.BACKEND_PORT);
if (port) {
return new URL(`${protocol}://${host}:${port}`);
} else {
return new URL(`${protocol}://${host}`);
}
},
};

Expand Down

0 comments on commit 28663cf

Please sign in to comment.