@enfyra/sdk-nuxt 0.3.28 → 0.3.29

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/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "0.3.28",
7
+ "version": "0.3.29",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../../src/runtime/utils/server/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAgB,MAAM,IAAI,CAAC;AAa3C,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,4BA4B7D"}
1
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../../src/runtime/utils/server/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAgB,MAAM,IAAI,CAAC;AAa3C,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,4BAmC7D"}
@@ -16,12 +16,15 @@ export function proxyToAPI(event, customPath) {
16
16
  const headers = event.context.proxyHeaders || {};
17
17
  const isWebSocket = event.node.req.headers["upgrade"]?.toLowerCase() === "websocket";
18
18
  if (isWebSocket) {
19
+ const originalUrl = event.node.req.url || "";
20
+ event.node.req.url = rawPath;
19
21
  proxy.web(event.node.req, event.node.res, {
20
- target: targetUrl,
22
+ target: config.public?.enfyraSDK?.apiUrl || process.env.API_URL || "http://localhost:1105",
21
23
  ws: true,
22
24
  changeOrigin: true,
23
25
  headers
24
26
  });
27
+ event.node.req.url = originalUrl;
25
28
  return void 0;
26
29
  }
27
30
  return proxyRequest(event, targetUrl, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enfyra/sdk-nuxt",
3
- "version": "0.3.28",
3
+ "version": "0.3.29",
4
4
  "type": "module",
5
5
  "description": "Nuxt SDK for Enfyra CMS",
6
6
  "repository": {
@@ -24,14 +24,21 @@ export function proxyToAPI(event: H3Event, customPath?: string) {
24
24
  const isWebSocket = event.node.req.headers['upgrade']?.toLowerCase() === 'websocket';
25
25
 
26
26
  if (isWebSocket) {
27
- // For WebSocket, use http-proxy directly and return immediately
28
- // The proxy will handle the upgrade asynchronously
27
+ // Modify req.url to remove the apiPrefix before proxying
28
+ // The incoming request is /api/chat/test-room but backend expects /chat/test-room
29
+ const originalUrl = event.node.req.url || '';
30
+ event.node.req.url = rawPath;
31
+
32
+ // For WebSocket, use http-proxy directly
29
33
  proxy.web(event.node.req, event.node.res, {
30
- target: targetUrl,
34
+ target: config.public?.enfyraSDK?.apiUrl || process.env.API_URL || 'http://localhost:1105',
31
35
  ws: true,
32
36
  changeOrigin: true,
33
37
  headers,
34
38
  });
39
+
40
+ // Restore original url
41
+ event.node.req.url = originalUrl;
35
42
  // Return undefined to signal we've handled the response asynchronously
36
43
  return undefined;
37
44
  }