@mundogamernetwork/shared-ui 1.1.42 → 1.1.44

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mundogamernetwork/shared-ui",
3
- "version": "1.1.42",
3
+ "version": "1.1.44",
4
4
  "description": "Mundo Gamer Network - Shared UI Layer (Nuxt 3)",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -100,10 +100,17 @@ export function getHttpService(): AxiosInstance {
100
100
  return _httpService;
101
101
  }
102
102
 
103
- const httpService = new Proxy({} as AxiosInstance, {
103
+ // The target must be a function so the Proxy is callable: callers use BOTH
104
+ // httpService(config) (axios instance invoked as a function) and
105
+ // httpService.get(...). A Proxy over {} only supports property access, so
106
+ // httpService(config) threw "httpService is not a function".
107
+ const httpService = new Proxy(function () {} as unknown as AxiosInstance, {
104
108
  get(_target, prop) {
105
109
  return (getHttpService() as any)[prop];
106
110
  },
111
+ apply(_target, _thisArg, args: any[]) {
112
+ return (getHttpService() as any)(...args);
113
+ },
107
114
  });
108
115
 
109
116
  export default httpService;
@@ -10,8 +10,17 @@ interface SerializeObject {
10
10
  }
11
11
 
12
12
  const getNetworkBaseUrl = () => {
13
- const config = useRuntimeConfig();
14
- return config.public.mgSharedUi?.networkBaseUrl || import.meta.env.VITE_BASE_URL_NETWORK;
13
+ // useRuntimeConfig() needs the active Nuxt instance and throws when called
14
+ // outside a setup context — these service functions run from async Pinia
15
+ // actions (loadPreviewData -> store -> service), where on SSR the context
16
+ // is already gone. Fall back to the build-time env so the fetch still works.
17
+ try {
18
+ const fromConfig = useRuntimeConfig().public.mgSharedUi?.networkBaseUrl;
19
+ if (fromConfig) return fromConfig as string;
20
+ } catch (_) {
21
+ // outside Nuxt context — use the env fallback below
22
+ }
23
+ return import.meta.env.VITE_BASE_URL_NETWORK;
15
24
  };
16
25
 
17
26
  export const complexSerialize = function (obj: SerializeObject): string {