bazis 0.100.2 → 0.100.3

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.
@@ -231,7 +231,8 @@ export class HttpServer implements HostedService {
231
231
  error: (error) => this.transportError(error),
232
232
  }),
233
233
  );
234
- } this.reportStarted(routes);
234
+ }
235
+ this.reportStarted(routes);
235
236
  }
236
237
 
237
238
  /** Routes and the address for the startup screen. */
@@ -369,7 +370,8 @@ export class HttpServer implements HostedService {
369
370
  }
370
371
  }
371
372
 
372
- private async dispatch(request: Request, clientIp?: string): Promise<Response> {
373
+ private async dispatch(incoming: Request, clientIp?: string): Promise<Response> {
374
+ const request = this.withAbsoluteUrl(incoming);
373
375
  let response: Response;
374
376
  try {
375
377
  response = await this.handle(request, clientIp);
@@ -395,6 +397,18 @@ export class HttpServer implements HostedService {
395
397
  return response;
396
398
  }
397
399
 
400
+ /**
401
+ * HTTP/1.0 allows a request without `Host`; Bun then gives a path, not a
402
+ * URL. Such a request is addressed to this server, so it gets the server's
403
+ * own origin and the rest of the pipeline sees an ordinary absolute URL.
404
+ */
405
+ private withAbsoluteUrl(request: Request): Request {
406
+ if (URL.canParse(request.url)) return request;
407
+ const server = this.server;
408
+ const host = server?.hostname === undefined || server.hostname === "0.0.0.0" || server.hostname === "::" ? "localhost" : server.hostname.includes(":") ? `[${server.hostname}]` : server.hostname;
409
+ return new Request(new URL(request.url, `http://${host}:${server?.port ?? 80}`).href, request);
410
+ }
411
+
398
412
  private async handle(request: Request, clientIp?: string): Promise<Response> {
399
413
  const url = new URL(request.url);
400
414
 
@@ -232,7 +232,7 @@ export class CodexAppServerClient implements CodexClient {
232
232
  if (method === "account/updated") this.modelCache = undefined;
233
233
  }, () => { this.clearLogin(); this.modelCache = undefined; });
234
234
  const initialized = await client.request("initialize", {
235
- clientInfo: { name: "bazis", title: "Bazis", version: "0.100.2" }, capabilities: { experimentalApi: true },
235
+ clientInfo: { name: "bazis", title: "Bazis", version: "0.100.3" }, capabilities: { experimentalApi: true },
236
236
  }, 15_000, signal);
237
237
  if (resolve(text(initialized.codexHome, 4096)) !== this.paths.home) throw new CodexError("PROTOCOL_ERROR");
238
238
  client.notify("initialized");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bazis",
3
- "version": "0.100.2",
3
+ "version": "0.100.3",
4
4
  "description": "Modular backend framework for Bun in TypeScript: DI wired by codegen, HTTP, a PostgreSQL ORM, JWT, WebSocket, agents and a CLI.",
5
5
  "license": "MIT",
6
6
  "author": "Alexander Alenin",