@niledatabase/server 5.0.0-alpha.6 → 5.0.0-alpha.7

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/index.js CHANGED
@@ -2863,17 +2863,22 @@ function bindHandleOnRequest(instance) {
2863
2863
  }
2864
2864
  const ext = await create2(instance);
2865
2865
  if (ext.onRequest) {
2866
- const modified = await ext.onRequest(_init.request);
2867
- if (modified?.headers) {
2868
- const modHeaders = new Headers(modified.headers);
2869
- const cookie = modHeaders.get("cookie");
2866
+ await ext.onRequest(_init.request);
2867
+ const updatedContext = instance.getContext();
2868
+ if (updatedContext?.headers) {
2869
+ const cookie = updatedContext.headers.get("cookie");
2870
2870
  if (cookie) {
2871
2871
  params.headers.set("cookie", cookie);
2872
- debug(`${ext.id ?? create2.name} modified cookie`);
2872
+ }
2873
+ if (updatedContext.tenantId) {
2874
+ params.headers.set(
2875
+ TENANT_COOKIE,
2876
+ String(updatedContext.headers.get(TENANT_COOKIE))
2877
+ );
2873
2878
  }
2874
2879
  }
2880
+ debug(`${ext.id ?? create2.name} ran onRequest`);
2875
2881
  }
2876
- debug(`${ext.id ?? create2.name} ran onRequest`);
2877
2882
  }
2878
2883
  }
2879
2884
  };
@@ -3051,6 +3056,7 @@ var Server = class {
3051
3056
  for (const [key17, value] of Object.entries(merged)) {
3052
3057
  this.#headers.set(key17, value);
3053
3058
  }
3059
+ this.#config.logger("[handleHeaders]").debug(JSON.stringify(merged));
3054
3060
  this.#config.headers = this.#headers;
3055
3061
  }
3056
3062
  /**