Skip to content

Commit 8aa0edf

Browse files
committed
🔧 update frontend code to dynamically detect api-gw url
1 parent 84e1183 commit 8aa0edf

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
VITE_NODE_ENV=development
2+
VITE_VUE_APP_API_URL=http://localhost:8083
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
VITE_NODE_ENV=production
2+
VITE_VUE_APP_API_URL=

personalization-webcomponents/src/checklist-preview.ce.vue

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
<p>
2020
<b>{{ service.serviceName }} (ID: {{ service.id }})</b><br>
2121
<span>{{ service.summary }}</span><br><br>
22-
<span>
23-
<b>Public URL</b>: <i>{{ service.publicUrl }}</i><br>
24-
<b>Has Responsibilities</b>: {{ service.hasResponsibilities ? "✅" : "❌" }}<br>
25-
<b>Is External</b>: {{ service.isExternal ? "✅" : "❌" }}<br>
26-
</span>
2722
<div v-if="service.onlineServices">
2823
<b>Online-Services:</b>
2924
<ul>
@@ -50,7 +45,7 @@ import customIconsSprite from "@muenchen/muc-patternlab-vue/assets/icons/custom-
5045
import mucIconsSprite from "@muenchen/muc-patternlab-vue/assets/icons/muc-icons.svg?raw";
5146
import SkeletonLoader from "@/components/common/skeleton-loader.vue";
5247
import {onMounted, ref} from "vue";
53-
import {LOCALSTORAGE_KEY_SERVICENAVIGATOR_RESULT} from "@/util/constants.ts";
48+
import {getAPIBaseURL, LOCALSTORAGE_KEY_SERVICENAVIGATOR_RESULT} from "@/util/constants.ts";
5449
import type {ServiceNavigatorResult} from "@/api/servicenavigator/ServiceNavigatorResult.ts";
5550
import type {SNService} from "@/api/servicenavigator/ServiceNavigatorLookup.ts";
5651
@@ -66,7 +61,7 @@ onMounted(() => {
6661
loading.value = false;
6762
} else {
6863
const snResult = JSON.parse(serviceNavigatorResultString) as ServiceNavigatorResult;
69-
const url = "http://localhost:8083/public/api/backend-service/servicenavigator?ids=" + snResult.services.join(",");
64+
const url = getAPIBaseURL() + "/public/api/backend-service/servicenavigator?ids=" + snResult.services.join(",");
7065
fetch(url)
7166
.then(resp => {
7267
if (resp.ok) {

personalization-webcomponents/src/util/constants.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ export function getChecklistIconByTitle(checklistTitle: string) {
1616
"https://stadt.muenchen.de/dam/Home/lhm_common/service-navigator/10483311.svg",
1717
}[checklistTitle];
1818
}
19+
20+
export function getAPIBaseURL(): String {
21+
if (import.meta.env.VITE_VUE_APP_API_URL) {
22+
return import.meta.env.VITE_VUE_APP_API_URL;
23+
} else {
24+
return new URL(import.meta.url).origin;
25+
}
26+
}

0 commit comments

Comments
 (0)