@base44-preview/sdk 0.8.38-pr.230.05d5213 → 0.8.39-pr.202.dea4a9b

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/dist/client.js +11 -0
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -346,6 +346,7 @@ export function createClientFromRequest(request) {
346
346
  const serverUrlHeader = request.headers.get("Base44-Api-Url");
347
347
  const functionsVersion = request.headers.get("Base44-Functions-Version");
348
348
  const stateHeader = request.headers.get("Base44-State");
349
+ const dataEnvHeader = request.headers.get("X-Data-Env");
349
350
  if (!appId) {
350
351
  throw new Error("Base44-App-Id header is required, but is was not found on the request");
351
352
  }
@@ -373,6 +374,16 @@ export function createClientFromRequest(request) {
373
374
  if (stateHeader) {
374
375
  additionalHeaders["Base44-State"] = stateHeader;
375
376
  }
377
+ // Propagate the data environment so entity operations from the function stay
378
+ // in the same environment (e.g. test data) as the triggering request. This
379
+ // matters for the user-scoped client: unlike the service token, the user JWT
380
+ // carries no data-env, so without forwarding this header the callbacks fall
381
+ // back to production data even when the app runs in test-data mode.
382
+ // Forward only the known closed set (matches the backend contract) rather
383
+ // than relaying an arbitrary attacker-supplied header value onward.
384
+ if (dataEnvHeader === "dev" || dataEnvHeader === "prod") {
385
+ additionalHeaders["X-Data-Env"] = dataEnvHeader;
386
+ }
376
387
  return createClient({
377
388
  serverUrl: serverUrlHeader || "https://base44.app",
378
389
  appId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.38-pr.230.05d5213",
3
+ "version": "0.8.39-pr.202.dea4a9b",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",