Skip to content

Commit 1f1e8fe

Browse files
committed
getting rid of hardcoded url and localhost fallback
1 parent 47e232f commit 1f1e8fe

5 files changed

Lines changed: 35 additions & 6 deletions

File tree

apps/api-manager/src/hooks.server.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ import { createOpeyNotebookDynamicEntityIfNeeded } from "$lib/server/opey/opeyNo
1717

1818
declare const process: { env: Record<string, string | undefined>; argv: string[] };
1919

20+
if (!publicEnv.PUBLIC_OBP_BASE_URL) {
21+
throw new Error(
22+
'PUBLIC_OBP_BASE_URL is not set. Configure it on the running container before starting api-manager.'
23+
);
24+
}
25+
2026
// Constants
2127
const DEFAULT_PORT = 3003;
2228

apps/api-manager/src/lib/components/OpeyChat.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@
5050
splash?: Snippet; // If set, will render the splash screen snippet until the first message is sent
5151
// upon which the splash screen will dissapear
5252
}
53+
if (!env.PUBLIC_OPEY_BASE_URL) {
54+
throw new Error(
55+
'PUBLIC_OPEY_BASE_URL is not set. Configure it on the running container so the Opey chat can reach the backend.'
56+
);
57+
}
58+
5359
// Default chat options
5460
const defaultChatOptions: OpeyChatOptions = {
55-
baseUrl: env.PUBLIC_OPEY_BASE_URL || 'http://localhost:5000',
61+
baseUrl: env.PUBLIC_OPEY_BASE_URL,
5662
displayHeader: true,
5763
currentlyActiveUserName: 'Guest',
5864
displayConnectionPips: true,

apps/portal/src/hooks.server.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ import { healthCheckRegistry, OIDCHealthCheckService } from '@obp/shared/health-
1717
import { redisService } from '$lib/redis/services/RedisService';
1818
import { RedisHealthCheckService } from '$lib/health-check/services/RedisHealthCheckService';
1919

20+
if (!publicEnv.PUBLIC_OBP_BASE_URL) {
21+
throw new Error(
22+
'PUBLIC_OBP_BASE_URL is not set. Configure it on the running container before starting the portal.'
23+
);
24+
}
25+
2026
// Constants
2127
const DEFAULT_PORT = 5174;
2228

apps/portal/src/lib/components/OpeyChat.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@
5050
splash?: Snippet; // If set, will render the splash screen snippet until the first message is sent
5151
// upon which the splash screen will dissapear
5252
}
53+
if (!env.PUBLIC_OPEY_BASE_URL) {
54+
throw new Error(
55+
'PUBLIC_OPEY_BASE_URL is not set. Configure it on the running container so the Opey chat can reach the backend.'
56+
);
57+
}
58+
5359
// Default chat options
5460
const defaultChatOptions: OpeyChatOptions = {
55-
baseUrl: env.PUBLIC_OPEY_BASE_URL || 'http://localhost:5000',
61+
baseUrl: env.PUBLIC_OPEY_BASE_URL,
5662
displayHeader: true,
5763
currentlyActiveUserName: 'Guest',
5864
displayConnectionPips: true,

packages/shared/src/lib/components/OpeyChat.svelte

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@
5050
splash?: Snippet; // If set, will render the splash screen snippet until the first message is sent
5151
// upon which the splash screen will dissapear
5252
}
53-
// Default chat options
54-
const defaultChatOptions: OpeyChatOptions = {
55-
baseUrl: 'http://localhost:5000',
53+
// Default chat options (baseUrl must be supplied by the consuming app)
54+
const defaultChatOptions: Omit<OpeyChatOptions, 'baseUrl'> = {
5655
displayHeader: true,
5756
currentlyActiveUserName: 'Guest',
5857
displayConnectionPips: true,
@@ -61,7 +60,13 @@
6160
6261
let { opeyChatOptions, userAuthenticated = false, splash }: Props = $props();
6362
// Merge default options with the provided options
64-
const options = { ...defaultChatOptions, ...opeyChatOptions };
63+
const options = { ...defaultChatOptions, ...opeyChatOptions } as OpeyChatOptions;
64+
65+
if (!options.baseUrl) {
66+
throw new Error(
67+
'OpeyChat: opeyChatOptions.baseUrl is required. Pass the Opey backend URL from the consuming app.'
68+
);
69+
}
6570
6671
// Initialize session state and services
6772

0 commit comments

Comments
 (0)