@mundogamernetwork/shared-ui 1.1.55 → 1.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -12,14 +12,25 @@ const SUPPORTED_LOCALES = ['en', 'pt-BR', 'es', 'de', 'ro', 'ar-AE'];
|
|
|
12
12
|
const routePath = route.path.split('/');
|
|
13
13
|
const lang = SUPPORTED_LOCALES.find(l => routePath.includes(l)) || 'en';
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const config = useRuntimeConfig();
|
|
16
|
+
// apiBaseURL may be undefined at build time on some deployments — fall back to
|
|
17
|
+
// a relative path so the SSR node process at least resolves against the same host.
|
|
18
|
+
const apiBase = (config.public.apiBaseURL as string) || '';
|
|
16
19
|
|
|
17
|
-
const { data: keyData, error: fetchError, pending } = await useAsyncData(
|
|
20
|
+
const { data: keyData, error: fetchError, pending, refresh } = await useAsyncData(
|
|
18
21
|
`public-key-${slug}`,
|
|
19
22
|
() => $fetch<any>(`${apiBase}/public/keys/${slug}`, { params: { lang } }),
|
|
20
|
-
{ lazy: false },
|
|
23
|
+
{ lazy: false, server: !!apiBase },
|
|
21
24
|
);
|
|
22
25
|
|
|
26
|
+
// If SSR produced no data (e.g. apiBase was empty during SSR), run a client-side
|
|
27
|
+
// fetch once mounted so the request appears in DevTools and the page can recover.
|
|
28
|
+
onMounted(async () => {
|
|
29
|
+
if (!keyData.value && !pending.value) {
|
|
30
|
+
await refresh();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
23
34
|
const key = computed(() => keyData.value?.data || null);
|
|
24
35
|
const loading = pending;
|
|
25
36
|
const error = computed(() => !!fetchError.value || (!pending.value && !key.value));
|