@njinlabs/njin 0.6.0 → 0.6.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/modules/img.ts +11 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@njinlabs/njin",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "A modern framework for building company profiles, landing pages, and content-driven websites.",
5
5
  "type": "module",
6
6
  "keywords": ["bun", "elysia", "surrealdb", "edgejs", "cms", "framework"],
@@ -85,7 +85,17 @@ const img = makeModule(() => {
85
85
  let imageData: ArrayBuffer;
86
86
 
87
87
  if (url.startsWith("/")) {
88
- const resp = await fetch(`http://localhost:${getConfig().port}${url}`);
88
+ // A real network fetch to localhost:<port> only works when app.listen() actually bound
89
+ // that port — under njin-supervisor's worker mode (NJIN_WORKER=1, see core/worker.ts)
90
+ // nothing does, requests arrive via postMessage and are handled in-process instead, so
91
+ // that socket was never listening and this always failed with a connection error.
92
+ // Calling the same in-process Elysia instance's handle() works in both modes, and skips
93
+ // an unnecessary self-round-trip even outside worker mode. The origin is taken from the
94
+ // *incoming* request rather than hardcoded — routing itself only cares about
95
+ // pathname+query, but a handler further down that inspects request.url (absolute-URL
96
+ // generation, host-based logic, ...) should see the same scheme/host this request
97
+ // actually arrived on, not a fake one that may not match across environments.
98
+ const resp = await elysia().handle(new Request(`${new URL(request.url).origin}${url}`));
89
99
  if (!resp.ok) return new Response("Image not found", { status: 404 });
90
100
  imageData = await resp.arrayBuffer();
91
101
  } else {