vercel 54.15.1 → 54.17.0

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 (54) hide show
  1. package/dist/chunks/{add-BHCMFK52.js → add-QQY6QOTO.js} +5 -5
  2. package/dist/chunks/{chunk-4TL5EF3A.js → chunk-2F6JT2OC.js} +4 -1
  3. package/dist/chunks/{chunk-AWD3IGXU.js → chunk-3NR6OYDV.js} +1 -1
  4. package/dist/chunks/{chunk-RWRYDAUG.js → chunk-4D42VZRX.js} +1 -1
  5. package/dist/chunks/{chunk-OOGTHUXU.js → chunk-5X7FBWLF.js} +6 -6
  6. package/dist/chunks/{chunk-CQ24PL4F.js → chunk-7AQDR2RX.js} +48 -9
  7. package/dist/chunks/{chunk-TAUAS27Y.js → chunk-7B44AIGE.js} +2 -2
  8. package/dist/chunks/{chunk-CBMMVXLH.js → chunk-A4B4JQVP.js} +11 -3
  9. package/dist/chunks/{chunk-AQWK7XXE.js → chunk-BRLY3Q4U.js} +18 -3
  10. package/dist/chunks/{chunk-D7U6YBVT.js → chunk-DDTKG4J3.js} +1 -1
  11. package/dist/chunks/{chunk-OEFNWW5M.js → chunk-E6FCE2XJ.js} +2 -2
  12. package/dist/chunks/{chunk-JNVCGTF2.js → chunk-HJ2TEW5Y.js} +1 -1
  13. package/dist/chunks/{chunk-PMUUPCDL.js → chunk-JFA4NUXP.js} +1 -1
  14. package/dist/chunks/{chunk-MABHXDYV.js → chunk-KTX4RQFM.js} +520 -133
  15. package/dist/chunks/{chunk-TDFUNPL7.js → chunk-KWCZRH7N.js} +5 -8
  16. package/dist/chunks/{chunk-B5DP7FOH.js → chunk-LGR4JRFA.js} +6 -6
  17. package/dist/chunks/{chunk-UJZ4RUU6.js → chunk-MS3WAXLU.js} +1 -1
  18. package/dist/chunks/{chunk-4OEXX4CB.js → chunk-NRIXI6V5.js} +1 -1
  19. package/dist/chunks/{chunk-4GQBO7KU.js → chunk-P5AZW6W6.js} +8 -2
  20. package/dist/chunks/{chunk-HIYWSGI7.js → chunk-Q77ALSXR.js} +3 -0
  21. package/dist/chunks/{chunk-5X6ILMYI.js → chunk-V7JDSYIZ.js} +3 -3
  22. package/dist/chunks/{chunk-UYC2Q5YZ.js → chunk-WJPWCLMH.js} +1 -1
  23. package/dist/chunks/{chunk-UEPXHHDN.js → chunk-YW7AYO7N.js} +1 -1
  24. package/dist/chunks/{compile-vercel-config-LUMMHFTD.js → compile-vercel-config-D2OQCK4B.js} +2 -2
  25. package/dist/chunks/{delete-X6VOLLCP.js → delete-VMW7FORM.js} +3 -3
  26. package/dist/chunks/{disable-LFH5IOCZ.js → disable-BDFZELDL.js} +3 -3
  27. package/dist/chunks/{discard-EVD33PAE.js → discard-WIN3BOXR.js} +3 -3
  28. package/dist/chunks/{edit-FL3SRS2I.js → edit-IZQX4XAG.js} +5 -5
  29. package/dist/chunks/{enable-HTU7LQK5.js → enable-RFODZ2L7.js} +3 -3
  30. package/dist/chunks/{export-R222C6IH.js → export-5CCLXZYT.js} +3 -3
  31. package/dist/chunks/{inspect-YYTAQP3A.js → inspect-GEUUTDBY.js} +4 -4
  32. package/dist/chunks/{list-SWJFJSEE.js → list-H35AGNO2.js} +3 -3
  33. package/dist/chunks/{list-AOJMWKA7.js → list-JIYDXQDJ.js} +4 -4
  34. package/dist/chunks/{ls-H7KDHFK6.js → ls-WPNFJAS6.js} +5 -5
  35. package/dist/chunks/{publish-O5VKBFJ6.js → publish-K7OPKXYC.js} +3 -3
  36. package/dist/chunks/{query-7UDJEOOR.js → query-MAN4NKU4.js} +3 -3
  37. package/dist/chunks/{reorder-ZPI6Q7DQ.js → reorder-GQ7BOQA7.js} +3 -3
  38. package/dist/chunks/{restore-7FNMEG4A.js → restore-MODYFJSP.js} +3 -3
  39. package/dist/chunks/{rm-U37YHRNF.js → rm-A45OKS6U.js} +5 -5
  40. package/dist/chunks/{routes-YEU33SON.js → routes-KUTLDFIF.js} +2 -2
  41. package/dist/chunks/{rule-inspect-CVI3TQHN.js → rule-inspect-HJCERQHK.js} +5 -5
  42. package/dist/chunks/{rules-ZTL4JCZO.js → rules-UNL3IB4P.js} +6 -6
  43. package/dist/chunks/{schema-LZ6VDRGM.js → schema-WOW2BATT.js} +3 -3
  44. package/dist/chunks/{update-O6FSP627.js → update-MOM4T2RN.js} +5 -5
  45. package/dist/commands/build/index.js +18 -18
  46. package/dist/commands/deploy/index.js +160 -13
  47. package/dist/commands/dev/index.js +665 -104
  48. package/dist/commands/env/index.js +6 -6
  49. package/dist/commands/link/index.js +47 -13
  50. package/dist/commands/list/index.js +5 -5
  51. package/dist/commands-bulk.js +44 -40
  52. package/dist/index.js +46 -42
  53. package/dist/version.mjs +1 -1
  54. package/package.json +21 -20
@@ -9,7 +9,7 @@ import {
9
9
  } from "../../chunks/chunk-2HSQ7YUK.js";
10
10
  import {
11
11
  getUpdateCommand
12
- } from "../../chunks/chunk-OEFNWW5M.js";
12
+ } from "../../chunks/chunk-E6FCE2XJ.js";
13
13
  import {
14
14
  highlight
15
15
  } from "../../chunks/chunk-V5P25P7F.js";
@@ -26,28 +26,29 @@ import {
26
26
  require_mime_types,
27
27
  require_npa,
28
28
  staticFiles
29
- } from "../../chunks/chunk-CQ24PL4F.js";
29
+ } from "../../chunks/chunk-7AQDR2RX.js";
30
30
  import "../../chunks/chunk-IB5L4LKZ.js";
31
31
  import {
32
32
  pickOverrides
33
- } from "../../chunks/chunk-4OEXX4CB.js";
33
+ } from "../../chunks/chunk-NRIXI6V5.js";
34
34
  import "../../chunks/chunk-YI3JV6GM.js";
35
35
  import {
36
36
  displayDetectedServices,
37
37
  printProjectNotFoundError,
38
38
  readConfig,
39
39
  setupAndLink
40
- } from "../../chunks/chunk-5X6ILMYI.js";
40
+ } from "../../chunks/chunk-V7JDSYIZ.js";
41
41
  import "../../chunks/chunk-QH7WYDEP.js";
42
42
  import {
43
43
  getLocalPathConfig
44
- } from "../../chunks/chunk-UJZ4RUU6.js";
45
- import "../../chunks/chunk-4TL5EF3A.js";
44
+ } from "../../chunks/chunk-MS3WAXLU.js";
45
+ import "../../chunks/chunk-2F6JT2OC.js";
46
46
  import {
47
47
  help
48
- } from "../../chunks/chunk-AWD3IGXU.js";
48
+ } from "../../chunks/chunk-3NR6OYDV.js";
49
49
  import {
50
50
  VERCEL_DIR,
51
+ VERCEL_OIDC_TOKEN,
51
52
  findRepoRoot,
52
53
  getLinkedProject,
53
54
  getVercelDirectory,
@@ -69,10 +70,10 @@ import {
69
70
  resolveProjectCwd,
70
71
  tryDetectServices,
71
72
  validateConfig
72
- } from "../../chunks/chunk-MABHXDYV.js";
73
+ } from "../../chunks/chunk-KTX4RQFM.js";
73
74
  import {
74
75
  TelemetryClient
75
- } from "../../chunks/chunk-HIYWSGI7.js";
76
+ } from "../../chunks/chunk-Q77ALSXR.js";
76
77
  import {
77
78
  buildCommandWithYes,
78
79
  outputActionRequired
@@ -4821,7 +4822,7 @@ var require_requires_port = __commonJS({
4821
4822
  var require_common = __commonJS({
4822
4823
  "../../node_modules/.pnpm/http-proxy-node16@1.0.6_debug@3.1.0/node_modules/http-proxy-node16/lib/http-proxy/common.js"(exports2) {
4823
4824
  var common = exports2;
4824
- var url3 = __require("url");
4825
+ var url4 = __require("url");
4825
4826
  var extend = Object.assign;
4826
4827
  var required = require_requires_port();
4827
4828
  var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i;
@@ -4869,7 +4870,7 @@ var require_common = __commonJS({
4869
4870
  }
4870
4871
  var target = options[forward || "target"];
4871
4872
  var targetPath = target && options.prependPath !== false ? target.path || "" : "";
4872
- var outgoingPath = !options.toProxy ? url3.parse(req.url).path || "" : req.url;
4873
+ var outgoingPath = !options.toProxy ? url4.parse(req.url).path || "" : req.url;
4873
4874
  outgoingPath = !options.ignorePath ? outgoingPath : "";
4874
4875
  outgoing.path = common.urlJoin(targetPath, outgoingPath);
4875
4876
  if (options.changeOrigin) {
@@ -4892,11 +4893,11 @@ var require_common = __commonJS({
4892
4893
  };
4893
4894
  common.urlJoin = function() {
4894
4895
  var args2 = Array.prototype.slice.call(arguments), queryParams = [], queryParamRaw = "", retSegs;
4895
- args2.forEach((url4, index) => {
4896
- var qpStart = url4.indexOf("?");
4896
+ args2.forEach((url5, index) => {
4897
+ var qpStart = url5.indexOf("?");
4897
4898
  if (qpStart !== -1) {
4898
- queryParams.push(url4.substring(qpStart + 1));
4899
- args2[index] = url4.substring(0, qpStart);
4899
+ queryParams.push(url5.substring(qpStart + 1));
4900
+ args2[index] = url5.substring(0, qpStart);
4900
4901
  }
4901
4902
  });
4902
4903
  queryParamRaw = queryParams.filter(Boolean).join("&");
@@ -4934,7 +4935,7 @@ var require_common = __commonJS({
4934
4935
  // ../../node_modules/.pnpm/http-proxy-node16@1.0.6_debug@3.1.0/node_modules/http-proxy-node16/lib/http-proxy/passes/web-outgoing.js
4935
4936
  var require_web_outgoing = __commonJS({
4936
4937
  "../../node_modules/.pnpm/http-proxy-node16@1.0.6_debug@3.1.0/node_modules/http-proxy-node16/lib/http-proxy/passes/web-outgoing.js"(exports2, module2) {
4937
- var url3 = __require("url");
4938
+ var url4 = __require("url");
4938
4939
  var common = require_common();
4939
4940
  var redirectRegex = /^201|30(1|2|7|8)$/;
4940
4941
  module2.exports = {
@@ -4972,8 +4973,8 @@ var require_web_outgoing = __commonJS({
4972
4973
  },
4973
4974
  setRedirectHostRewrite: function setRedirectHostRewrite(req, res, proxyRes, options) {
4974
4975
  if ((options.hostRewrite || options.autoRewrite || options.protocolRewrite) && proxyRes.headers["location"] && redirectRegex.test(proxyRes.statusCode)) {
4975
- var target = url3.parse(options.target);
4976
- var u = url3.parse(proxyRes.headers["location"]);
4976
+ var target = url4.parse(options.target);
4977
+ var u = url4.parse(proxyRes.headers["location"]);
4977
4978
  if (target.host != u.host) {
4978
4979
  return;
4979
4980
  }
@@ -5652,8 +5653,8 @@ var require_debug2 = __commonJS({
5652
5653
  // ../../node_modules/.pnpm/follow-redirects@1.16.0_debug@3.1.0/node_modules/follow-redirects/index.js
5653
5654
  var require_follow_redirects = __commonJS({
5654
5655
  "../../node_modules/.pnpm/follow-redirects@1.16.0_debug@3.1.0/node_modules/follow-redirects/index.js"(exports2, module2) {
5655
- var url3 = __require("url");
5656
- var URL2 = url3.URL;
5656
+ var url4 = __require("url");
5657
+ var URL2 = url4.URL;
5657
5658
  var http2 = __require("http");
5658
5659
  var https = __require("https");
5659
5660
  var Writable2 = __require("stream").Writable;
@@ -5914,7 +5915,7 @@ var require_follow_redirects = __commonJS({
5914
5915
  for (var event of events) {
5915
5916
  request.on(event, eventHandlers[event]);
5916
5917
  }
5917
- this._currentUrl = /^\//.test(this._options.path) ? url3.format(this._options) : (
5918
+ this._currentUrl = /^\//.test(this._options.path) ? url4.format(this._options) : (
5918
5919
  // When making a request to a proxy, […]
5919
5920
  // a client MUST send the target URI in absolute-form […].
5920
5921
  this._options.path
@@ -5982,7 +5983,7 @@ var require_follow_redirects = __commonJS({
5982
5983
  var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
5983
5984
  var currentUrlParts = parseUrl(this._currentUrl);
5984
5985
  var currentHost = currentHostHeader || currentUrlParts.host;
5985
- var currentUrl = /^\w+:/.test(location) ? this._currentUrl : url3.format(Object.assign(currentUrlParts, { host: currentHost }));
5986
+ var currentUrl = /^\w+:/.test(location) ? this._currentUrl : url4.format(Object.assign(currentUrlParts, { host: currentHost }));
5986
5987
  var redirectUrl = resolveUrl(location, currentUrl);
5987
5988
  debug("redirecting to", redirectUrl.href);
5988
5989
  this._isRedirect = true;
@@ -6060,7 +6061,7 @@ var require_follow_redirects = __commonJS({
6060
6061
  if (useNativeURL) {
6061
6062
  parsed = new URL2(input);
6062
6063
  } else {
6063
- parsed = validateUrl(url3.parse(input));
6064
+ parsed = validateUrl(url4.parse(input));
6064
6065
  if (!isString(parsed.protocol)) {
6065
6066
  throw new InvalidUrlError({ input });
6066
6067
  }
@@ -6068,7 +6069,7 @@ var require_follow_redirects = __commonJS({
6068
6069
  return parsed;
6069
6070
  }
6070
6071
  function resolveUrl(relative3, base) {
6071
- return useNativeURL ? new URL2(relative3, base) : parseUrl(url3.resolve(base, relative3));
6072
+ return useNativeURL ? new URL2(relative3, base) : parseUrl(url4.resolve(base, relative3));
6072
6073
  }
6073
6074
  function validateUrl(input) {
6074
6075
  if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
@@ -6285,16 +6286,16 @@ var require_web_incoming = __commonJS({
6285
6286
  var proxyError = createErrorHandler(proxyReq, options.target);
6286
6287
  req.on("error", proxyError);
6287
6288
  proxyReq.on("error", proxyError);
6288
- function createErrorHandler(proxyReq2, url3) {
6289
+ function createErrorHandler(proxyReq2, url4) {
6289
6290
  return function proxyError2(err) {
6290
6291
  if (req.socket.destroyed && err.code === "ECONNRESET") {
6291
- server.emit("econnreset", err, req, res, url3);
6292
+ server.emit("econnreset", err, req, res, url4);
6292
6293
  return proxyReq2.abort();
6293
6294
  }
6294
6295
  if (clb) {
6295
- clb(err, req, res, url3);
6296
+ clb(err, req, res, url4);
6296
6297
  } else {
6297
- server.emit("error", err, req, res, url3);
6298
+ server.emit("error", err, req, res, url4);
6298
6299
  }
6299
6300
  };
6300
6301
  }
@@ -15783,7 +15784,7 @@ var require_src2 = __commonJS({
15783
15784
  var path6 = __require("path");
15784
15785
  var { createHash } = __require("crypto");
15785
15786
  var { realpath, lstat, createReadStream, readdir } = __require("fs");
15786
- var url3 = require_urlparser();
15787
+ var url4 = require_urlparser();
15787
15788
  var slasher = require_glob_slash();
15788
15789
  var minimatch3 = require_minimatch2();
15789
15790
  var pathToRegExp = require_path_to_regexp();
@@ -15835,7 +15836,7 @@ var require_src2 = __commonJS({
15835
15836
  }
15836
15837
  const { keys, results } = matches;
15837
15838
  const props = {};
15838
- const { protocol } = url3.parse(destination);
15839
+ const { protocol } = url4.parse(destination);
15839
15840
  const normalizedDest = protocol ? destination : slasher(destination);
15840
15841
  const toPath = pathToRegExp.compile(normalizedDest);
15841
15842
  for (let index = 0; index < keys.length; index++) {
@@ -16190,7 +16191,7 @@ var require_src2 = __commonJS({
16190
16191
  acceptsJSON = request.headers.accept.includes("application/json");
16191
16192
  }
16192
16193
  try {
16193
- relativePath = decodeURIComponent(url3.parse(request.url).pathname);
16194
+ relativePath = decodeURIComponent(url4.parse(request.url).pathname);
16194
16195
  } catch (err) {
16195
16196
  return sendError("/", response, acceptsJSON, current, handlers, config, {
16196
16197
  statusCode: 400,
@@ -16771,7 +16772,7 @@ var import_once = __toESM(require_dist7(), 1);
16771
16772
  var import_directory = __toESM(require_directory(), 1);
16772
16773
  var import_get_port2 = __toESM(require_get_port(), 1);
16773
16774
  var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
16774
- import url2, { URL } from "url";
16775
+ import url3, { URL } from "url";
16775
16776
  import http from "http";
16776
16777
  import { randomBytes as randomBytes2 } from "crypto";
16777
16778
  import { watch } from "chokidar";
@@ -16831,7 +16832,7 @@ function relative2(a, b) {
16831
16832
 
16832
16833
  // src/util/dev/router.ts
16833
16834
  var import_pcre_to_regexp = __toESM(require_dist6(), 1);
16834
- import url from "url";
16835
+ import url2 from "url";
16835
16836
 
16836
16837
  // src/util/dev/is-url.ts
16837
16838
  function isURL(str) {
@@ -16885,6 +16886,343 @@ function formatQueryString(query) {
16885
16886
  return s || null;
16886
16887
  }
16887
16888
 
16889
+ // src/util/dev/transforms.ts
16890
+ import url from "url";
16891
+ function resolveTransforms(transforms, ctx) {
16892
+ if (!transforms || transforms.length === 0) {
16893
+ return [];
16894
+ }
16895
+ return transforms.map((transform) => {
16896
+ if (transform.type === "request.path") {
16897
+ return {
16898
+ ...transform,
16899
+ args: resolveString(transform.args, transform, ctx)
16900
+ };
16901
+ }
16902
+ return {
16903
+ ...transform,
16904
+ target: { key: resolveKey(transform.target.key, transform, ctx) },
16905
+ args: resolveArgs(transform.args, transform, ctx)
16906
+ };
16907
+ });
16908
+ }
16909
+ function applyResponseTransforms(headers, transforms) {
16910
+ for (const transform of transforms) {
16911
+ if (transform.type === "response.headers" && "target" in transform) {
16912
+ applyTransform(headers, transform, true);
16913
+ }
16914
+ }
16915
+ }
16916
+ function applyRequestTransforms(req, transforms) {
16917
+ if (transforms.length === 0) {
16918
+ return;
16919
+ }
16920
+ applyRequestHeaderTransforms(req.headers, transforms);
16921
+ const parsed = url.parse(req.url || "/");
16922
+ const query = parseQueryString(parsed.search);
16923
+ applyQueryTransforms(query, transforms);
16924
+ const newPath = getRequestPath(transforms);
16925
+ if (newPath !== void 0) {
16926
+ parsed.pathname = newPath;
16927
+ }
16928
+ parsed.search = formatQueryString(query);
16929
+ req.url = url.format(parsed);
16930
+ }
16931
+ function hasResponseTransforms(transforms) {
16932
+ return transforms.some((t) => t.type === "response.headers");
16933
+ }
16934
+ function resolveKey(key, _transform, ctx) {
16935
+ if (typeof key === "string") {
16936
+ return expandCaptureGroups(key, ctx.match, ctx.keys);
16937
+ }
16938
+ return key;
16939
+ }
16940
+ function resolveArgs(args2, transform, ctx) {
16941
+ if (typeof args2 === "string") {
16942
+ return resolveString(args2, transform, ctx);
16943
+ }
16944
+ if (Array.isArray(args2)) {
16945
+ return args2.map(
16946
+ (a) => typeof a === "string" ? resolveString(a, transform, ctx) : a
16947
+ );
16948
+ }
16949
+ return args2;
16950
+ }
16951
+ function resolveString(value, transform, ctx) {
16952
+ let resolved = expandCaptureGroups(value, ctx.match, ctx.keys);
16953
+ if (transform.env && transform.env.length > 0 && ctx.env) {
16954
+ resolved = expandEnvVars(resolved, transform.env, ctx.env);
16955
+ }
16956
+ return resolved;
16957
+ }
16958
+ function expandCaptureGroups(str, match, keys) {
16959
+ return str.replace(/\$([0-9A-Za-z_]+)/g, (whole, name) => {
16960
+ const namedIdx = keys.indexOf(name);
16961
+ if (namedIdx !== -1) {
16962
+ return match[namedIdx + 1] ?? "";
16963
+ }
16964
+ if (/^[0-9]+$/.test(name)) {
16965
+ const n = parseInt(name, 10);
16966
+ if (n < match.length) {
16967
+ return match[n] ?? "";
16968
+ }
16969
+ }
16970
+ return whole;
16971
+ });
16972
+ }
16973
+ function expandEnvVars(str, allowlist, env) {
16974
+ const allowed = new Set(allowlist);
16975
+ return str.replace(
16976
+ /\$\{([A-Za-z_][A-Za-z0-9_]*)\}|\$([A-Za-z_][A-Za-z0-9_]*)/g,
16977
+ (match, braced, bare) => {
16978
+ const name = braced ?? bare;
16979
+ if (!allowed.has(name) || env[name] === void 0) {
16980
+ return match;
16981
+ }
16982
+ return env[name];
16983
+ }
16984
+ );
16985
+ }
16986
+ function applyRequestHeaderTransforms(headers, transforms) {
16987
+ for (const transform of transforms) {
16988
+ if (transform.type === "request.headers" && "target" in transform) {
16989
+ applyTransform(headers, transform, true);
16990
+ }
16991
+ }
16992
+ }
16993
+ function applyQueryTransforms(query, transforms) {
16994
+ for (const transform of transforms) {
16995
+ if (transform.type === "request.query" && "target" in transform) {
16996
+ applyTransform(query, transform, false);
16997
+ }
16998
+ }
16999
+ for (const key of Object.keys(query)) {
17000
+ const value = query[key];
17001
+ if (value === void 0) {
17002
+ delete query[key];
17003
+ } else if (typeof value === "string") {
17004
+ query[key] = [value];
17005
+ }
17006
+ }
17007
+ }
17008
+ var HEADER_NAME_RE = /^[-\w]+$/;
17009
+ var HEADER_VALUE_RE = /^[-\w:;.,/\\"'?!(){}[\]@<>=+*#$&`|~%^ ]+$/;
17010
+ function isValidHeaderName(name) {
17011
+ return name.length > 0 && HEADER_NAME_RE.test(name);
17012
+ }
17013
+ function isValidHeaderValue(value) {
17014
+ return value.length > 0 && HEADER_VALUE_RE.test(value);
17015
+ }
17016
+ function hasValidHeaderArgs(args2) {
17017
+ if (typeof args2 === "string") {
17018
+ return isValidHeaderValue(args2);
17019
+ }
17020
+ if (Array.isArray(args2)) {
17021
+ return args2.every(isValidHeaderValue);
17022
+ }
17023
+ return false;
17024
+ }
17025
+ function applyTransform(data, transform, isHeader) {
17026
+ const keySelector = transform.target?.key;
17027
+ if (keySelector == null) {
17028
+ return;
17029
+ }
17030
+ if (isHeader && (transform.op === "set" || transform.op === "append")) {
17031
+ if (typeof keySelector === "string" && !isValidHeaderName(keySelector)) {
17032
+ return;
17033
+ }
17034
+ if (!hasValidHeaderArgs(transform.args)) {
17035
+ return;
17036
+ }
17037
+ }
17038
+ const matchedKeys = findMatchingKeys(data, keySelector);
17039
+ switch (transform.op) {
17040
+ case "set":
17041
+ opSet(data, matchedKeys, keySelector, transform.args);
17042
+ break;
17043
+ case "append":
17044
+ opAppend(data, matchedKeys, keySelector, transform.args, isHeader);
17045
+ break;
17046
+ case "delete":
17047
+ opDelete(data, matchedKeys, transform.args, isHeader);
17048
+ break;
17049
+ default:
17050
+ break;
17051
+ }
17052
+ }
17053
+ function isValidRequestPath(path6) {
17054
+ if (path6 === "" || path6.length > 2048) {
17055
+ return false;
17056
+ }
17057
+ if (path6[0] !== "/" || path6.startsWith("//")) {
17058
+ return false;
17059
+ }
17060
+ if (/[?#]/.test(path6)) {
17061
+ return false;
17062
+ }
17063
+ for (let i = 0; i < path6.length; i++) {
17064
+ const code = path6.charCodeAt(i);
17065
+ if (code <= 32 || code === 127) {
17066
+ return false;
17067
+ }
17068
+ }
17069
+ return true;
17070
+ }
17071
+ function getRequestPath(transforms) {
17072
+ let path6;
17073
+ for (const transform of transforms) {
17074
+ if (transform.type === "request.path" && transform.op === "set" && typeof transform.args === "string" && isValidRequestPath(transform.args)) {
17075
+ path6 = transform.args;
17076
+ }
17077
+ }
17078
+ return path6;
17079
+ }
17080
+ function findMatchingKeys(data, keyPattern) {
17081
+ const matched = [];
17082
+ for (const key of Object.keys(data)) {
17083
+ if (matchesRule(key, keyPattern)) {
17084
+ matched.push(key);
17085
+ }
17086
+ }
17087
+ return matched;
17088
+ }
17089
+ function matchesRule(candidate, rule) {
17090
+ candidate = candidate.toLowerCase();
17091
+ if (rule == null) {
17092
+ return true;
17093
+ }
17094
+ if (typeof rule === "string") {
17095
+ return candidate === rule.toLowerCase();
17096
+ }
17097
+ const r = rule;
17098
+ for (const [op, val] of Object.entries(r)) {
17099
+ if (val === void 0) {
17100
+ continue;
17101
+ }
17102
+ switch (op) {
17103
+ case "eq":
17104
+ if (candidate !== String(val).toLowerCase())
17105
+ return false;
17106
+ break;
17107
+ case "neq":
17108
+ if (candidate === val.toLowerCase())
17109
+ return false;
17110
+ break;
17111
+ case "inc":
17112
+ if (!val.some((v) => candidate === v.toLowerCase()))
17113
+ return false;
17114
+ break;
17115
+ case "ninc":
17116
+ if (val.some((v) => candidate === v.toLowerCase()))
17117
+ return false;
17118
+ break;
17119
+ case "pre":
17120
+ if (!candidate.startsWith(String(val).toLowerCase()))
17121
+ return false;
17122
+ break;
17123
+ case "suf":
17124
+ if (!candidate.endsWith(String(val).toLowerCase()))
17125
+ return false;
17126
+ break;
17127
+ case "sub":
17128
+ if (!candidate.includes(String(val).toLowerCase()))
17129
+ return false;
17130
+ break;
17131
+ case "gt":
17132
+ if (!(Number(candidate) > val))
17133
+ return false;
17134
+ break;
17135
+ case "gte":
17136
+ if (!(Number(candidate) >= val))
17137
+ return false;
17138
+ break;
17139
+ case "lt":
17140
+ if (!(Number(candidate) < val))
17141
+ return false;
17142
+ break;
17143
+ case "lte":
17144
+ if (!(Number(candidate) <= val))
17145
+ return false;
17146
+ break;
17147
+ default:
17148
+ break;
17149
+ }
17150
+ }
17151
+ return true;
17152
+ }
17153
+ function opSet(data, matchedKeys, keySelector, args2) {
17154
+ for (const key of matchedKeys) {
17155
+ data[key] = args2;
17156
+ }
17157
+ if (matchedKeys.length === 0 && typeof keySelector === "string" && data[keySelector] === void 0 && !isEmptyArgs(args2)) {
17158
+ data[keySelector] = args2;
17159
+ }
17160
+ }
17161
+ function opAppend(data, matchedKeys, keySelector, args2, isHeader) {
17162
+ if (isEmptyArgs(args2)) {
17163
+ return;
17164
+ }
17165
+ const toAppend = typeof args2 === "string" ? [args2] : args2 ?? [];
17166
+ for (const key of matchedKeys) {
17167
+ const next = [...toValueList(data[key], isHeader), ...toAppend];
17168
+ setTransformValue(data, key, fromValueList(next));
17169
+ }
17170
+ if (matchedKeys.length === 0 && typeof keySelector === "string") {
17171
+ setTransformValue(data, keySelector, fromValueList(toAppend));
17172
+ }
17173
+ }
17174
+ function opDelete(data, matchedKeys, args2, isHeader) {
17175
+ if (args2 == null) {
17176
+ for (const key of matchedKeys) {
17177
+ delete data[key];
17178
+ }
17179
+ return;
17180
+ }
17181
+ const patterns = typeof args2 === "string" ? [args2] : args2;
17182
+ for (const key of matchedKeys) {
17183
+ const kept = toValueList(data[key], isHeader).filter(
17184
+ (value) => !patterns.some((pattern) => matchesRule(value, pattern))
17185
+ );
17186
+ setTransformValue(data, key, fromValueList(kept));
17187
+ }
17188
+ }
17189
+ function toValueList(value, isHeader) {
17190
+ if (value === void 0) {
17191
+ return [];
17192
+ }
17193
+ if (Array.isArray(value)) {
17194
+ return value;
17195
+ }
17196
+ const str = String(value);
17197
+ if (isHeader && str.includes(",")) {
17198
+ return str.split(",").map((v) => v.trim()).filter((v) => v !== "");
17199
+ }
17200
+ return [str];
17201
+ }
17202
+ function fromValueList(values) {
17203
+ if (values.length === 0) {
17204
+ return void 0;
17205
+ }
17206
+ if (values.length === 1) {
17207
+ return values[0];
17208
+ }
17209
+ return values;
17210
+ }
17211
+ function setTransformValue(data, key, value) {
17212
+ if (value === void 0) {
17213
+ delete data[key];
17214
+ } else {
17215
+ data[key] = value;
17216
+ }
17217
+ }
17218
+ function isEmptyArgs(args2) {
17219
+ if (args2 == null)
17220
+ return true;
17221
+ if (typeof args2 === "string")
17222
+ return args2 === "";
17223
+ return args2.length === 0;
17224
+ }
17225
+
16888
17226
  // src/util/dev/router.ts
16889
17227
  function resolveRouteParameters(str, match, keys) {
16890
17228
  return str.replace(/\$([1-9a-zA-Z]+)/g, (_, param2) => {
@@ -16916,12 +17254,14 @@ function getRoutesTypes(routes = []) {
16916
17254
  }
16917
17255
  async function devRouter(reqUrl = "/", reqMethod, routes, devServer, vercelConfig, previousHeaders, missRoutes, phase) {
16918
17256
  let result;
16919
- let { pathname: reqPathname, search: reqSearch } = url.parse(reqUrl);
17257
+ let { pathname: reqPathname, search: reqSearch } = url2.parse(reqUrl);
16920
17258
  reqPathname = reqPathname || "/";
16921
17259
  const reqQuery = parseQueryString(reqSearch);
16922
17260
  const combinedHeaders = { ...previousHeaders };
16923
17261
  let status;
16924
17262
  let isContinue = false;
17263
+ const requestTransforms = [];
17264
+ let responseTransforms;
16925
17265
  if (routes) {
16926
17266
  let idx = -1;
16927
17267
  for (const routeConfig of routes) {
@@ -16939,6 +17279,15 @@ async function devRouter(reqUrl = "/", reqMethod, routes, devServer, vercelConfi
16939
17279
  const matcher = (0, import_pcre_to_regexp.default)(`%${src}%${flags}`, keys);
16940
17280
  const match = matcher.exec(reqPathname) || matcher.exec(reqPathname.substring(1));
16941
17281
  if (match) {
17282
+ const routeTransforms = routeConfig.transforms ? resolveTransforms(routeConfig.transforms, {
17283
+ match,
17284
+ keys,
17285
+ env: devServer?.envConfigs.runEnv
17286
+ }) : [];
17287
+ const isServiceMarker = typeof routeConfig.destination === "object" && routeConfig.destination !== null && routeConfig.destination.type === "service";
17288
+ if (!isServiceMarker && routeTransforms.length > 0) {
17289
+ requestTransforms.push(...routeTransforms);
17290
+ }
16942
17291
  let destPath = reqPathname;
16943
17292
  if (routeConfig.dest) {
16944
17293
  destPath = resolveRouteParameters(routeConfig.dest, match, keys);
@@ -16958,13 +17307,16 @@ async function devRouter(reqUrl = "/", reqMethod, routes, devServer, vercelConfi
16958
17307
  if (routeConfig.status) {
16959
17308
  status = routeConfig.status;
16960
17309
  }
17310
+ if (routeTransforms.length > 0) {
17311
+ responseTransforms = routeTransforms;
17312
+ }
16961
17313
  reqPathname = destPath;
16962
17314
  isContinue = true;
16963
17315
  continue;
16964
17316
  }
16965
17317
  const isDestUrl = isURL(destPath);
16966
17318
  if (routeConfig.check && devServer && vercelConfig && phase !== "hit" && !isDestUrl) {
16967
- let { pathname } = url.parse(destPath);
17319
+ let { pathname } = url2.parse(destPath);
16968
17320
  pathname = pathname || "/";
16969
17321
  const hasDestFile = await devServer.hasFilesystem(
16970
17322
  pathname,
@@ -16973,6 +17325,9 @@ async function devRouter(reqUrl = "/", reqMethod, routes, devServer, vercelConfi
16973
17325
  if (!hasDestFile) {
16974
17326
  if (routeConfig.status && phase !== "miss") {
16975
17327
  } else if (missRoutes && missRoutes.length > 0) {
17328
+ if (routeTransforms.length > 0) {
17329
+ responseTransforms = routeTransforms;
17330
+ }
16976
17331
  const missResult = await devRouter(
16977
17332
  destPath,
16978
17333
  reqMethod,
@@ -16984,6 +17339,15 @@ async function devRouter(reqUrl = "/", reqMethod, routes, devServer, vercelConfi
16984
17339
  "miss"
16985
17340
  );
16986
17341
  if (missResult.found) {
17342
+ if (requestTransforms.length > 0) {
17343
+ missResult.requestTransforms = [
17344
+ ...requestTransforms,
17345
+ ...missResult.requestTransforms ?? []
17346
+ ];
17347
+ }
17348
+ if (!missResult.responseTransforms && responseTransforms) {
17349
+ missResult.responseTransforms = responseTransforms;
17350
+ }
16987
17351
  return missResult;
16988
17352
  } else {
16989
17353
  reqPathname = destPath;
@@ -16993,11 +17357,19 @@ async function devRouter(reqUrl = "/", reqMethod, routes, devServer, vercelConfi
16993
17357
  if (routeConfig.status && phase === "miss") {
16994
17358
  status = routeConfig.status;
16995
17359
  }
17360
+ if (routeTransforms.length > 0) {
17361
+ responseTransforms = routeTransforms;
17362
+ }
16996
17363
  reqPathname = destPath;
16997
17364
  continue;
16998
17365
  }
16999
17366
  }
17000
17367
  }
17368
+ const effectiveStatus = routeConfig.status || status;
17369
+ const isRedirectExit = typeof effectiveStatus === "number" && effectiveStatus >= 300 && effectiveStatus < 400;
17370
+ if (!isServiceMarker && !isRedirectExit && routeTransforms.length > 0) {
17371
+ responseTransforms = routeTransforms;
17372
+ }
17001
17373
  if (isDestUrl) {
17002
17374
  result = {
17003
17375
  found: true,
@@ -17010,14 +17382,16 @@ async function devRouter(reqUrl = "/", reqMethod, routes, devServer, vercelConfi
17010
17382
  query: reqQuery,
17011
17383
  matched_route: routeConfig,
17012
17384
  matched_route_idx: idx,
17013
- phase
17385
+ phase,
17386
+ requestTransforms,
17387
+ responseTransforms
17014
17388
  };
17015
17389
  break;
17016
17390
  } else {
17017
17391
  if (!destPath.startsWith("/")) {
17018
17392
  destPath = `/${destPath}`;
17019
17393
  }
17020
- let { pathname: destPathname, search: destSearch } = url.parse(destPath);
17394
+ let { pathname: destPathname, search: destSearch } = url2.parse(destPath);
17021
17395
  destPathname = destPathname || "/";
17022
17396
  const destQuery = parseQueryString(destSearch);
17023
17397
  Object.assign(destQuery, reqQuery);
@@ -17032,7 +17406,9 @@ async function devRouter(reqUrl = "/", reqMethod, routes, devServer, vercelConfi
17032
17406
  query: destQuery,
17033
17407
  matched_route: routeConfig,
17034
17408
  matched_route_idx: idx,
17035
- phase
17409
+ phase,
17410
+ requestTransforms,
17411
+ responseTransforms
17036
17412
  };
17037
17413
  break;
17038
17414
  }
@@ -17048,7 +17424,9 @@ async function devRouter(reqUrl = "/", reqMethod, routes, devServer, vercelConfi
17048
17424
  isDestUrl: false,
17049
17425
  query: reqQuery,
17050
17426
  headers: combinedHeaders,
17051
- phase
17427
+ phase,
17428
+ requestTransforms,
17429
+ responseTransforms
17052
17430
  };
17053
17431
  }
17054
17432
  return result;
@@ -17420,6 +17798,16 @@ async function getBuildMatches(vercelConfig, cwd, devServer, fileList) {
17420
17798
  mapToEntrypoint.set(src, originalSrc);
17421
17799
  }
17422
17800
  }
17801
+ if (buildConfig.config?.framework === "node" && !fileList.includes(src)) {
17802
+ const originalSrc = src;
17803
+ const existing = fileList.find(
17804
+ (path6) => /^(?:src\/)?server\.[cm]?[jt]s$/.test(path6)
17805
+ );
17806
+ if (existing) {
17807
+ src = existing;
17808
+ mapToEntrypoint.set(src, originalSrc);
17809
+ }
17810
+ }
17423
17811
  if (buildConfig.config?.framework === "go" && !fileList.includes(src)) {
17424
17812
  const originalSrc = src;
17425
17813
  const goEntrypoints = [
@@ -18262,7 +18650,7 @@ var ServicesOrchestrator = class {
18262
18650
  if (targetPort === void 0) {
18263
18651
  continue;
18264
18652
  }
18265
- perServiceEnv[binding.env] = `http://127.0.0.1:${targetPort}/`;
18653
+ perServiceEnv[binding.env] = `http://127.0.0.1:${targetPort}`;
18266
18654
  }
18267
18655
  const env = cloneEnv(
18268
18656
  {
@@ -18568,8 +18956,8 @@ var ServicesOrchestrator = class {
18568
18956
  `Triggering scheduled job ${import_chalk.default.bold(serviceName)} (schedule: ${import_chalk.default.cyan(schedule)})`
18569
18957
  );
18570
18958
  try {
18571
- const url3 = `http://${managed.host}:${managed.port}${cronPath}`;
18572
- const res = await fetch(url3, { method: "POST" });
18959
+ const url4 = `http://${managed.host}:${managed.port}${cronPath}`;
18960
+ const res = await fetch(url4, { method: "POST" });
18573
18961
  output_manager_default.debug(
18574
18962
  `Cron trigger for "${serviceName}" responded with status ${res.status}`
18575
18963
  );
@@ -18606,6 +18994,8 @@ var QueueBroker = class {
18606
18994
  constructor(services, getServiceOrigin) {
18607
18995
  this.getServiceOrigin = getServiceOrigin;
18608
18996
  this.messages = /* @__PURE__ */ new Map();
18997
+ this.idempotencyRecords = /* @__PURE__ */ new Map();
18998
+ this.duplicateMessages = /* @__PURE__ */ new Map();
18609
18999
  this.consumerGroups = [];
18610
19000
  this.deliveryState = /* @__PURE__ */ new Map();
18611
19001
  for (const service of services) {
@@ -18635,6 +19025,30 @@ var QueueBroker = class {
18635
19025
  enqueue(queueName, payload, contentType2, options) {
18636
19026
  const messageId = randomBytes(16).toString("hex");
18637
19027
  const retentionMs = (options?.retentionSeconds ?? 0) > 0 ? options.retentionSeconds * 1e3 : DEFAULT_RETENTION;
19028
+ const idempotencyRecordKey = options?.idempotencyKey ? `${queueName}:${options.idempotencyKey}` : void 0;
19029
+ if (idempotencyRecordKey) {
19030
+ const record = this.idempotencyRecords.get(idempotencyRecordKey);
19031
+ if (record && record.expiresAt > Date.now()) {
19032
+ this.duplicateMessages.set(messageId, {
19033
+ queueName,
19034
+ originalMessageId: record.messageId,
19035
+ expiresAt: Date.now() + retentionMs
19036
+ });
19037
+ output_manager_default.debug(
19038
+ `queues: skipped duplicate message for queue "${queueName}"`
19039
+ );
19040
+ return { messageId };
19041
+ }
19042
+ if (record) {
19043
+ this.idempotencyRecords.delete(idempotencyRecordKey);
19044
+ }
19045
+ }
19046
+ if (idempotencyRecordKey) {
19047
+ this.idempotencyRecords.set(idempotencyRecordKey, {
19048
+ messageId,
19049
+ expiresAt: Date.now() + retentionMs
19050
+ });
19051
+ }
18638
19052
  const message2 = {
18639
19053
  messageId,
18640
19054
  payload,
@@ -18676,6 +19090,17 @@ var QueueBroker = class {
18676
19090
  }
18677
19091
  return { messageId };
18678
19092
  }
19093
+ getOriginalMessageIdForDuplicate(queueName, messageId) {
19094
+ const duplicate = this.duplicateMessages.get(messageId);
19095
+ if (!duplicate || duplicate.queueName !== queueName) {
19096
+ return null;
19097
+ }
19098
+ if (duplicate.expiresAt <= Date.now()) {
19099
+ this.duplicateMessages.delete(messageId);
19100
+ return null;
19101
+ }
19102
+ return duplicate.originalMessageId;
19103
+ }
18679
19104
  receiveById(messageId, consumerGroup) {
18680
19105
  const message2 = this.messages.get(messageId);
18681
19106
  if (!message2)
@@ -18870,6 +19295,16 @@ var QueueBroker = class {
18870
19295
  }
18871
19296
  tick() {
18872
19297
  const now = Date.now();
19298
+ for (const [key, record] of this.idempotencyRecords) {
19299
+ if (record.expiresAt <= now) {
19300
+ this.idempotencyRecords.delete(key);
19301
+ }
19302
+ }
19303
+ for (const [messageId, record] of this.duplicateMessages) {
19304
+ if (record.expiresAt <= now) {
19305
+ this.duplicateMessages.delete(messageId);
19306
+ }
19307
+ }
18873
19308
  for (const group of this.consumerGroups) {
18874
19309
  const groupDeliveries = this.deliveryState.get(group.id);
18875
19310
  if (!groupDeliveries)
@@ -18992,8 +19427,8 @@ function parseListen(str, defaultPort = 3e3) {
18992
19427
  if (!isNaN(port)) {
18993
19428
  return [port];
18994
19429
  }
18995
- const url3 = parse(str);
18996
- switch (url3.protocol) {
19430
+ const url4 = parse(str);
19431
+ switch (url4.protocol) {
18997
19432
  case "pipe:": {
18998
19433
  const cutStr = str.replace(/^pipe:/, "");
18999
19434
  if (cutStr.slice(0, 4) !== "\\\\.\\") {
@@ -19002,25 +19437,25 @@ function parseListen(str, defaultPort = 3e3) {
19002
19437
  return [cutStr];
19003
19438
  }
19004
19439
  case "unix:":
19005
- if (!url3.pathname) {
19440
+ if (!url4.pathname) {
19006
19441
  throw new Error(`Invalid UNIX domain socket endpoint: ${str}`);
19007
19442
  }
19008
- return [url3.pathname];
19443
+ return [url4.pathname];
19009
19444
  case "tcp:":
19010
- url3.port = url3.port || String(defaultPort);
19011
- return [parseInt(url3.port, 10), url3.hostname ?? void 0];
19445
+ url4.port = url4.port || String(defaultPort);
19446
+ return [parseInt(url4.port, 10), url4.hostname ?? void 0];
19012
19447
  default:
19013
- if (!url3.slashes) {
19014
- if (url3.protocol === null) {
19015
- return [defaultPort, url3.pathname ?? void 0];
19448
+ if (!url4.slashes) {
19449
+ if (url4.protocol === null) {
19450
+ return [defaultPort, url4.pathname ?? void 0];
19016
19451
  }
19017
- port = Number(url3.hostname);
19018
- if (url3.protocol && !isNaN(port)) {
19019
- return [port, url3.protocol.substring(0, url3.protocol.length - 1)];
19452
+ port = Number(url4.hostname);
19453
+ if (url4.protocol && !isNaN(port)) {
19454
+ return [port, url4.protocol.substring(0, url4.protocol.length - 1)];
19020
19455
  }
19021
19456
  }
19022
19457
  throw new Error(
19023
- `Unknown \`--listen\` scheme (protocol): ${url3.protocol}`
19458
+ `Unknown \`--listen\` scheme (protocol): ${url4.protocol}`
19024
19459
  );
19025
19460
  }
19026
19461
  }
@@ -19052,6 +19487,7 @@ var DevCommandExitError = class extends Error {
19052
19487
  };
19053
19488
  var DevServer = class {
19054
19489
  constructor(cwd, options) {
19490
+ this.responseTransformsByReq = /* @__PURE__ */ new WeakMap();
19055
19491
  this.clearVercelConfigPromise = () => {
19056
19492
  this.getVercelConfigPromise = null;
19057
19493
  };
@@ -19092,12 +19528,19 @@ var DevServer = class {
19092
19528
  /**
19093
19529
  * This is the equivalent to now-proxy exit_with_status() function.
19094
19530
  */
19095
- this.exitWithStatus = async (match, routeResult, phase, req, res, requestId) => {
19531
+ this.exitWithStatus = async (match, routeResult, phase, req, res, requestId, responseTransforms) => {
19096
19532
  const { status, headers, dest } = routeResult;
19097
19533
  const location = headers["location"] || dest;
19098
19534
  if (status && location && 300 <= status && status <= 399) {
19099
19535
  output_manager_default.debug(`Route found with redirect status code ${status}`);
19100
- await this.sendRedirect(req, res, requestId, location, status);
19536
+ await this.sendRedirect(
19537
+ req,
19538
+ res,
19539
+ requestId,
19540
+ location,
19541
+ status,
19542
+ responseTransforms
19543
+ );
19101
19544
  return true;
19102
19545
  }
19103
19546
  if (!match && status && phase !== "miss") {
@@ -19105,7 +19548,11 @@ var DevServer = class {
19105
19548
  return false;
19106
19549
  }
19107
19550
  output_manager_default.debug(`Route found with with status code ${status}`);
19108
- await this.sendError(req, res, requestId, "", status, headers);
19551
+ const errorHeaders = { ...headers };
19552
+ if (responseTransforms) {
19553
+ applyResponseTransforms(errorHeaders, responseTransforms);
19554
+ }
19555
+ await this.sendError(req, res, requestId, "", status, errorHeaders);
19109
19556
  return true;
19110
19557
  }
19111
19558
  return false;
@@ -19136,11 +19583,12 @@ var DevServer = class {
19136
19583
  const retentionSeconds = retentionHeader && !isNaN(parseInt(retentionHeader, 10)) ? parseInt(retentionHeader, 10) : void 0;
19137
19584
  const delayHeader = req.headers["vqs-delay-seconds"];
19138
19585
  const delaySeconds = delayHeader && !isNaN(parseInt(delayHeader, 10)) ? parseInt(delayHeader, 10) : void 0;
19586
+ const idempotencyKey = req.headers["vqs-idempotency-key"];
19139
19587
  const { messageId } = this.queueBroker.enqueue(
19140
19588
  topic,
19141
19589
  payload,
19142
19590
  contentType2,
19143
- { retentionSeconds, delaySeconds }
19591
+ { retentionSeconds, delaySeconds, idempotencyKey }
19144
19592
  );
19145
19593
  res.writeHead(201, {
19146
19594
  "Content-Type": "application/json",
@@ -19153,7 +19601,18 @@ var DevServer = class {
19153
19601
  /^([A-Za-z0-9_-]+)\/consumer\/([A-Za-z0-9_-]+)\/id\/([^/]+)$/
19154
19602
  );
19155
19603
  if (req.method === "POST" && receiveByIdMatch) {
19156
- const [, , consumer, messageId] = receiveByIdMatch;
19604
+ const [, queueName, consumer, messageId] = receiveByIdMatch;
19605
+ const originalMessageId = this.queueBroker.getOriginalMessageIdForDuplicate(queueName, messageId);
19606
+ if (originalMessageId) {
19607
+ res.writeHead(409, { "Content-Type": "application/json" });
19608
+ res.end(
19609
+ JSON.stringify({
19610
+ error: "This messageId was a duplicate - use originalMessageId instead",
19611
+ originalMessageId
19612
+ })
19613
+ );
19614
+ return;
19615
+ }
19157
19616
  const result = this.queueBroker.receiveById(messageId, consumer);
19158
19617
  if (!result) {
19159
19618
  res.writeHead(404);
@@ -19282,7 +19741,7 @@ ${partHeaders}\r
19282
19741
  */
19283
19742
  this.serveProjectAsNowV2 = async (req, res, requestId, vercelConfig, routes = vercelConfig.routes, callLevel = 0) => {
19284
19743
  const { debug } = output_manager_default;
19285
- const parsed = url2.parse(req.url || "/");
19744
+ const parsed = url3.parse(req.url || "/");
19286
19745
  if (typeof parsed.pathname === "string" && parsed.pathname.includes("//")) {
19287
19746
  let location = parsed.pathname.replace(/\/+/g, "/");
19288
19747
  if (parsed.search) {
@@ -19327,11 +19786,11 @@ ${partHeaders}\r
19327
19786
  const getReqUrl = (rr) => {
19328
19787
  if (rr.dest) {
19329
19788
  if (rr.query) {
19330
- const destParsed = url2.parse(rr.dest);
19789
+ const destParsed = url3.parse(rr.dest);
19331
19790
  const destQuery = parseQueryString(destParsed.search);
19332
19791
  Object.assign(destQuery, rr.query);
19333
19792
  destParsed.search = formatQueryString(destQuery);
19334
- return url2.format(destParsed);
19793
+ return url3.format(destParsed);
19335
19794
  }
19336
19795
  return rr.dest;
19337
19796
  }
@@ -19349,6 +19808,8 @@ ${partHeaders}\r
19349
19808
  let prevUrl = req.url;
19350
19809
  let prevHeaders = {};
19351
19810
  let middlewarePid;
19811
+ const requestTransforms = [];
19812
+ let responseTransforms;
19352
19813
  const middleware = [...this.buildMatches.values()].find(
19353
19814
  (m) => m.config?.middleware === true
19354
19815
  );
@@ -19357,8 +19818,8 @@ ${partHeaders}\r
19357
19818
  const { envConfigs, files, devCacheDir, cwd: workPath } = this;
19358
19819
  try {
19359
19820
  const { builder: builder2 } = middleware.builderWithPkg;
19360
- if (builder2.version === 3 || builder2.version === -1) {
19361
- startMiddlewareResult = await builder2.startDevServer?.({
19821
+ if (typeof builder2.startDevServer === "function") {
19822
+ startMiddlewareResult = await builder2.startDevServer({
19362
19823
  files,
19363
19824
  entrypoint: middleware.entrypoint,
19364
19825
  workPath,
@@ -19454,9 +19915,9 @@ ${partHeaders}\r
19454
19915
  return;
19455
19916
  }
19456
19917
  } else {
19457
- const rewriteUrlParsed = url2.parse(beforeRewriteUrl);
19458
- rewriteUrlParsed.search = url2.parse(rewritePath).search;
19459
- req.url = url2.format(rewriteUrlParsed);
19918
+ const rewriteUrlParsed = url3.parse(beforeRewriteUrl);
19919
+ rewriteUrlParsed.search = url3.parse(rewritePath).search;
19920
+ req.url = url3.format(rewriteUrlParsed);
19460
19921
  }
19461
19922
  debug(
19462
19923
  `Rewrote incoming HTTP URL from "${beforeRewriteUrl}" to "${req.url}"`
@@ -19500,6 +19961,12 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19500
19961
  missRoutes,
19501
19962
  phase
19502
19963
  );
19964
+ if (routeResult.requestTransforms) {
19965
+ requestTransforms.push(...routeResult.requestTransforms);
19966
+ }
19967
+ if (routeResult.responseTransforms) {
19968
+ responseTransforms = routeResult.responseTransforms;
19969
+ }
19503
19970
  if (routeResult.continue) {
19504
19971
  if (routeResult.dest) {
19505
19972
  prevUrl = getReqUrl(routeResult);
@@ -19514,15 +19981,18 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19514
19981
  res,
19515
19982
  requestId,
19516
19983
  routeResult.matched_route,
19517
- vercelConfig
19984
+ vercelConfig,
19985
+ requestTransforms,
19986
+ responseTransforms
19518
19987
  );
19519
19988
  }
19520
19989
  if (routeResult.isDestUrl) {
19521
- const destParsed = url2.parse(routeResult.dest);
19990
+ const destParsed = url3.parse(routeResult.dest);
19522
19991
  const destQuery = parseQueryString(destParsed.search);
19523
19992
  Object.assign(destQuery, routeResult.query);
19524
19993
  destParsed.search = formatQueryString(destQuery);
19525
- const destUrl = url2.format(destParsed);
19994
+ const destUrl = url3.format(destParsed);
19995
+ this.prepareTransforms(req, requestTransforms, responseTransforms);
19526
19996
  debug(`ProxyPass: ${destUrl}`);
19527
19997
  this.setResponseHeaders(res, requestId);
19528
19998
  return proxyPass(req, res, destUrl, this, requestId);
@@ -19540,7 +20010,8 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19540
20010
  phase,
19541
20011
  req,
19542
20012
  res,
19543
- requestId
20013
+ requestId,
20014
+ responseTransforms
19544
20015
  )) {
19545
20016
  return;
19546
20017
  }
@@ -19555,6 +20026,12 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19555
20026
  [],
19556
20027
  "miss"
19557
20028
  );
20029
+ if (routeResult.requestTransforms) {
20030
+ requestTransforms.push(...routeResult.requestTransforms);
20031
+ }
20032
+ if (routeResult.responseTransforms) {
20033
+ responseTransforms = routeResult.responseTransforms;
20034
+ }
19558
20035
  match = await findBuildMatch(
19559
20036
  this.buildMatches,
19560
20037
  this.files,
@@ -19568,7 +20045,8 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19568
20045
  phase,
19569
20046
  req,
19570
20047
  res,
19571
- requestId
20048
+ requestId,
20049
+ responseTransforms
19572
20050
  )) {
19573
20051
  return;
19574
20052
  }
@@ -19585,6 +20063,12 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19585
20063
  "hit"
19586
20064
  );
19587
20065
  routeResult.status = prevStatus;
20066
+ if (routeResult.requestTransforms) {
20067
+ requestTransforms.push(...routeResult.requestTransforms);
20068
+ }
20069
+ if (routeResult.responseTransforms) {
20070
+ responseTransforms = routeResult.responseTransforms;
20071
+ }
19588
20072
  }
19589
20073
  statusCode = routeResult.status;
19590
20074
  if (match) {
@@ -19618,6 +20102,12 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19618
20102
  routeResult = routeResultForError;
19619
20103
  statusCode = routeResultForError.status;
19620
20104
  match = matchForError;
20105
+ if (routeResult.requestTransforms) {
20106
+ requestTransforms.push(...routeResult.requestTransforms);
20107
+ }
20108
+ if (routeResult.responseTransforms) {
20109
+ responseTransforms = routeResult.responseTransforms;
20110
+ }
19621
20111
  } else if (matched_route && matched_route.src && !matched_route.dest) {
19622
20112
  debug(
19623
20113
  "Route without `dest` detected in error phase, attempting to exit early"
@@ -19628,7 +20118,8 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19628
20118
  "error",
19629
20119
  req,
19630
20120
  res,
19631
- requestId
20121
+ requestId,
20122
+ responseTransforms
19632
20123
  )) {
19633
20124
  return;
19634
20125
  }
@@ -19660,12 +20151,13 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19660
20151
  req.headers[name] = value;
19661
20152
  }
19662
20153
  this.setResponseHeaders(res, requestId);
19663
- const origUrl = url2.parse(req.url || "/");
20154
+ const origUrl = url3.parse(req.url || "/");
19664
20155
  const origQuery = parseQueryString(origUrl.search);
19665
20156
  origUrl.pathname = dest;
19666
20157
  Object.assign(origQuery, query);
19667
20158
  origUrl.search = formatQueryString(origQuery);
19668
- req.url = url2.format(origUrl);
20159
+ req.url = url3.format(origUrl);
20160
+ this.prepareTransforms(req, requestTransforms, responseTransforms);
19669
20161
  return proxyPass(req, res, upstream, this, requestId, false);
19670
20162
  }
19671
20163
  if (statusCode === 404 && routeResult.phase === "miss" || !this.renderDirectoryListing(req, res, requestPath, requestId)) {
@@ -19676,12 +20168,12 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19676
20168
  const buildRequestPath = match.buildResults.has(null) ? null : requestPath;
19677
20169
  const buildResult = match.buildResults.get(buildRequestPath);
19678
20170
  if (buildResult && Array.isArray(buildResult.routes) && buildResult.routes.length > 0) {
19679
- const origUrl = url2.parse(req.url || "/");
20171
+ const origUrl = url3.parse(req.url || "/");
19680
20172
  const origQuery = parseQueryString(origUrl.search);
19681
20173
  origUrl.pathname = dest;
19682
20174
  Object.assign(origQuery, query);
19683
20175
  origUrl.search = formatQueryString(origQuery);
19684
- const newUrl = url2.format(origUrl);
20176
+ const newUrl = url3.format(origUrl);
19685
20177
  debug(
19686
20178
  `Checking build result's ${buildResult.routes.length} \`routes\` to match ${newUrl}`
19687
20179
  );
@@ -19707,7 +20199,7 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19707
20199
  }
19708
20200
  }
19709
20201
  const { builder, pkg: builderPkg } = match.builderWithPkg;
19710
- if ((builder.version === 3 || builder.version === -1) && typeof builder.startDevServer === "function") {
20202
+ if (typeof builder.startDevServer === "function") {
19711
20203
  let devServerResult = null;
19712
20204
  try {
19713
20205
  const { envConfigs, files, devCacheDir, cwd: workPath } = this;
@@ -19749,19 +20241,21 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19749
20241
  }
19750
20242
  if (devServerResult) {
19751
20243
  requestId = generateRequestId(this.podId, true);
19752
- const { port, pid, shutdown } = devServerResult;
20244
+ const { port, pid, shutdown, persistent } = devServerResult;
19753
20245
  this.shutdownCallbacks.set(pid, shutdown);
19754
- res.once("close", () => {
19755
- this.killBuilderDevServer(pid);
19756
- });
20246
+ if (!persistent) {
20247
+ res.once("close", () => {
20248
+ this.killBuilderDevServer(pid);
20249
+ });
20250
+ }
19757
20251
  debug(
19758
20252
  `Proxying to "${builderPkg.name}" dev server (port=${port}, pid=${pid})`
19759
20253
  );
19760
- const origUrl = url2.parse(req.url || "/");
20254
+ const origUrl = url3.parse(req.url || "/");
19761
20255
  const origQuery = parseQueryString(origUrl.search);
19762
20256
  Object.assign(origQuery, query);
19763
20257
  origUrl.search = formatQueryString(origQuery);
19764
- req.url = url2.format({
20258
+ req.url = url3.format({
19765
20259
  pathname: origUrl.pathname,
19766
20260
  search: origUrl.search
19767
20261
  });
@@ -19769,6 +20263,7 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19769
20263
  for (const [name, value] of Object.entries(headers2)) {
19770
20264
  req.headers[name] = value;
19771
20265
  }
20266
+ this.prepareTransforms(req, requestTransforms, responseTransforms);
19772
20267
  this.setResponseHeaders(res, requestId);
19773
20268
  return proxyPass(
19774
20269
  req,
@@ -19793,6 +20288,7 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19793
20288
  for (const [name, value] of Object.entries(headers2)) {
19794
20289
  req.headers[name] = value;
19795
20290
  }
20291
+ this.prepareTransforms(req, requestTransforms, responseTransforms);
19796
20292
  this.setResponseHeaders(res, requestId);
19797
20293
  return proxyPass(req, res, this.devProcessOrigin, this, requestId, false);
19798
20294
  }
@@ -19807,6 +20303,12 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19807
20303
  switch (asset.type) {
19808
20304
  case "FileFsRef":
19809
20305
  this.setResponseHeaders(res, requestId);
20306
+ const staticResHeaders = {};
20307
+ applyResponseTransforms(staticResHeaders, responseTransforms ?? []);
20308
+ for (const [name, value] of Object.entries(staticResHeaders)) {
20309
+ if (value !== void 0)
20310
+ res.setHeader(name, value);
20311
+ }
19810
20312
  req.url = `/${basename(asset.fsPath)}`;
19811
20313
  return serveStaticFile(req, res, dirname2(asset.fsPath), {
19812
20314
  headers: [
@@ -19826,6 +20328,7 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19826
20328
  "Content-Length": asset.data.length,
19827
20329
  "Content-Type": asset.contentType || getMimeType(assetKey)
19828
20330
  };
20331
+ applyResponseTransforms(headers2, responseTransforms ?? []);
19829
20332
  this.setResponseHeaders(res, requestId, headers2);
19830
20333
  res.end(asset.data);
19831
20334
  return;
@@ -19840,14 +20343,16 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19840
20343
  return;
19841
20344
  }
19842
20345
  requestId = generateRequestId(this.podId, true);
19843
- const origUrl = url2.parse(req.url || "/");
20346
+ const origUrl = url3.parse(req.url || "/");
19844
20347
  const origQuery = parseQueryString(origUrl.search);
19845
20348
  Object.assign(origQuery, query);
19846
20349
  origUrl.search = formatQueryString(origQuery);
19847
- const path6 = url2.format({
20350
+ req.url = url3.format({
19848
20351
  pathname: origUrl.pathname,
19849
20352
  search: origUrl.search
19850
20353
  });
20354
+ applyRequestTransforms(req, requestTransforms);
20355
+ const path6 = req.url || "/";
19851
20356
  const body = await (0, import_raw_body.default)(req);
19852
20357
  const payload = {
19853
20358
  method: req.method || "GET",
@@ -19881,7 +20386,9 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19881
20386
  if (!statusCode) {
19882
20387
  res.statusCode = result.statusCode;
19883
20388
  }
19884
- this.setResponseHeaders(res, requestId, result.headers);
20389
+ const lambdaHeaders = result.headers ?? {};
20390
+ applyResponseTransforms(lambdaHeaders, responseTransforms ?? []);
20391
+ this.setResponseHeaders(res, requestId, lambdaHeaders);
19885
20392
  let resBody;
19886
20393
  if (result.encoding === "base64" && typeof result.body === "string") {
19887
20394
  resBody = Buffer.from(result.body, "base64");
@@ -19912,8 +20419,13 @@ Please ensure that ${cmd(err.path)} is properly installed`;
19912
20419
  ws: true,
19913
20420
  xfwd: true
19914
20421
  });
19915
- this.proxy.on("proxyRes", (proxyRes) => {
20422
+ this.proxy.on("proxyRes", (proxyRes, req) => {
19916
20423
  proxyRes.headers["server"] = "Vercel";
20424
+ const responseTransforms = this.responseTransformsByReq.get(req);
20425
+ if (responseTransforms) {
20426
+ this.responseTransformsByReq.delete(req);
20427
+ applyResponseTransforms(proxyRes.headers, responseTransforms);
20428
+ }
19917
20429
  });
19918
20430
  this.proxy.on("error", (err, req, res) => {
19919
20431
  output_manager_default.debug(
@@ -20226,7 +20738,7 @@ Please ensure that ${cmd(err.path)} is properly installed`;
20226
20738
  return void 0;
20227
20739
  }
20228
20740
  async _getVercelConfig() {
20229
- const { compileVercelConfig } = await import("../../chunks/compile-vercel-config-LUMMHFTD.js");
20741
+ const { compileVercelConfig } = await import("../../chunks/compile-vercel-config-D2OQCK4B.js");
20230
20742
  await compileVercelConfig(this.cwd);
20231
20743
  const configPath = getLocalPathConfig(this.cwd);
20232
20744
  const [
@@ -20249,7 +20761,8 @@ Please ensure that ${cmd(err.path)} is properly installed`;
20249
20761
  await this.exit();
20250
20762
  }
20251
20763
  vercelConfig.routes = maybeRoutes || [];
20252
- if (!vercelConfig.experimentalServices && (!vercelConfig.builds || vercelConfig.builds.length === 0)) {
20764
+ const hasResolvedServices = !!this.services && this.services.length > 0;
20765
+ if (!vercelConfig.experimentalServices && !hasResolvedServices && (!vercelConfig.builds || vercelConfig.builds.length === 0)) {
20253
20766
  const featHandleMiss = true;
20254
20767
  const { projectSettings, cleanUrls, trailingSlash } = vercelConfig;
20255
20768
  const files = (await staticFiles(this.cwd, {})).map(
@@ -20604,7 +21117,7 @@ Please ensure that ${cmd(err.path)} is properly installed`;
20604
21117
  this.server.on("upgrade", async (req, socket, head) => {
20605
21118
  await this.startPromise;
20606
21119
  if (this.orchestrator) {
20607
- const pathname2 = url2.parse(req.url || "/").pathname || "/";
21120
+ const pathname2 = url3.parse(req.url || "/").pathname || "/";
20608
21121
  const service = this.orchestrator.getServiceForRoute(pathname2);
20609
21122
  if (service) {
20610
21123
  const target = `http://${service.host}:${service.port}`;
@@ -20614,6 +21127,27 @@ Please ensure that ${cmd(err.path)} is properly installed`;
20614
21127
  this.proxy.ws(req, socket, head, { target });
20615
21128
  return;
20616
21129
  }
21130
+ const vercelConfig2 = await this.getVercelConfig();
21131
+ if (vercelConfig2.experimentalServicesV2 || vercelConfig2.services) {
21132
+ const routeResult = await devRouter(
21133
+ req.url || "/",
21134
+ req.method,
21135
+ vercelConfig2.routes,
21136
+ this,
21137
+ vercelConfig2
21138
+ );
21139
+ if (isServiceDestination(routeResult.matched_route)) {
21140
+ const { service: serviceName } = routeResult.matched_route.destination;
21141
+ const origin = this.orchestrator.getServiceOrigin(serviceName);
21142
+ if (origin) {
21143
+ output_manager_default.debug(
21144
+ `Detected "upgrade" event, proxying to service "${serviceName}" at ${origin}`
21145
+ );
21146
+ this.proxy.ws(req, socket, head, { target: origin });
21147
+ return;
21148
+ }
21149
+ }
21150
+ }
20617
21151
  output_manager_default.debug(
20618
21152
  `Detected "upgrade" event, but no matching service found for ${pathname2}`
20619
21153
  );
@@ -20626,10 +21160,10 @@ Please ensure that ${cmd(err.path)} is properly installed`;
20626
21160
  this.proxy.ws(req, socket, head, { target });
20627
21161
  return;
20628
21162
  }
20629
- const pathname = url2.parse(req.url || "/").pathname || "/";
21163
+ const pathname = url3.parse(req.url || "/").pathname || "/";
20630
21164
  for (const match of this.buildMatches.values()) {
20631
21165
  const { builder } = match.builderWithPkg;
20632
- if ((builder.version === 3 || builder.version === -1) && typeof builder.startDevServer === "function") {
21166
+ if (typeof builder.startDevServer === "function") {
20633
21167
  try {
20634
21168
  const result = await builder.startDevServer({
20635
21169
  files: this.files,
@@ -20796,10 +21330,14 @@ ${error_code}
20796
21330
  }
20797
21331
  res.end(body);
20798
21332
  }
20799
- async sendRedirect(req, res, requestId, location, statusCode = 302) {
21333
+ async sendRedirect(req, res, requestId, location, statusCode = 302, responseTransforms) {
20800
21334
  output_manager_default.debug(`Redirect ${statusCode}: ${location}`);
20801
21335
  res.statusCode = statusCode;
20802
- this.setResponseHeaders(res, requestId, { location });
21336
+ const redirectHeaders = { location };
21337
+ if (responseTransforms) {
21338
+ applyResponseTransforms(redirectHeaders, responseTransforms);
21339
+ }
21340
+ this.setResponseHeaders(res, requestId, redirectHeaders);
20803
21341
  let body;
20804
21342
  const { accept = "text/plain" } = req.headers;
20805
21343
  if (accept.includes("json")) {
@@ -20838,6 +21376,17 @@ ${error_code}
20838
21376
  res.setHeader(name, value);
20839
21377
  }
20840
21378
  }
21379
+ prepareTransforms(req, requestTransforms, responseTransforms) {
21380
+ if (requestTransforms && requestTransforms.length > 0) {
21381
+ applyRequestTransforms(req, requestTransforms);
21382
+ }
21383
+ if (responseTransforms && hasResponseTransforms(responseTransforms)) {
21384
+ this.responseTransformsByReq.set(req, responseTransforms);
21385
+ }
21386
+ }
21387
+ clearResponseTransforms(req) {
21388
+ this.responseTransformsByReq.delete(req);
21389
+ }
20841
21390
  /**
20842
21391
  * Returns the request `headers` that will be sent to the Lambda.
20843
21392
  */
@@ -20884,7 +21433,7 @@ ${error_code}
20884
21433
  }
20885
21434
  return this.serviceRoutesTable.get(serviceName) || [];
20886
21435
  }
20887
- async delegateToService(req, res, requestId, matchedRoute, vercelConfig) {
21436
+ async delegateToService(req, res, requestId, matchedRoute, vercelConfig, requestTransforms, responseTransforms) {
20888
21437
  const { debug } = output_manager_default;
20889
21438
  const { service: serviceName, path: destPath } = matchedRoute.destination;
20890
21439
  const origin = this.orchestrator?.getServiceOrigin(serviceName);
@@ -20901,7 +21450,7 @@ ${error_code}
20901
21450
  );
20902
21451
  return;
20903
21452
  }
20904
- const parsed = url2.parse(req.url || "/");
21453
+ const parsed = url3.parse(req.url || "/");
20905
21454
  const originalPathname = parsed.pathname || "/";
20906
21455
  let lookupPath = originalPathname;
20907
21456
  if (typeof destPath === "string" && matchedRoute.src) {
@@ -20915,6 +21464,10 @@ ${error_code}
20915
21464
  }
20916
21465
  const serviceRoutes = this.getServiceRouteTable(serviceName);
20917
21466
  const proxyHeaders = this.getProxyHeaders(req, requestId, false);
21467
+ const requestTransformsToApply = [
21468
+ ...requestTransforms ?? []
21469
+ ];
21470
+ let responseTransformsToApply = responseTransforms;
20918
21471
  if (serviceRoutes.length > 0) {
20919
21472
  const serviceResult = await devRouter(
20920
21473
  `${lookupPath}${parsed.search || ""}`,
@@ -20923,6 +21476,12 @@ ${error_code}
20923
21476
  this,
20924
21477
  vercelConfig
20925
21478
  );
21479
+ if (serviceResult.requestTransforms) {
21480
+ requestTransformsToApply.push(...serviceResult.requestTransforms);
21481
+ }
21482
+ if (serviceResult.responseTransforms) {
21483
+ responseTransformsToApply = serviceResult.responseTransforms;
21484
+ }
20926
21485
  const location = serviceResult.headers?.location;
20927
21486
  if (location && typeof serviceResult.status === "number" && serviceResult.status >= 300 && serviceResult.status < 400) {
20928
21487
  await this.sendRedirect(
@@ -20930,7 +21489,8 @@ ${error_code}
20930
21489
  res,
20931
21490
  requestId,
20932
21491
  location,
20933
- serviceResult.status
21492
+ serviceResult.status,
21493
+ responseTransformsToApply
20934
21494
  );
20935
21495
  return;
20936
21496
  }
@@ -20945,6 +21505,11 @@ ${error_code}
20945
21505
  for (const [name, value] of Object.entries(proxyHeaders)) {
20946
21506
  req.headers[name] = value;
20947
21507
  }
21508
+ this.prepareTransforms(
21509
+ req,
21510
+ requestTransformsToApply,
21511
+ responseTransformsToApply
21512
+ );
20948
21513
  this.setResponseHeaders(res, requestId);
20949
21514
  debug(`Delegating to service "${serviceName}": ${origin}`);
20950
21515
  return proxyPass(req, res, origin, this, requestId, false);
@@ -21170,6 +21735,7 @@ function proxyPass(req, res, dest, devServer, requestId, ignorePath = true) {
21170
21735
  res,
21171
21736
  { target: dest, ignorePath },
21172
21737
  (error2) => {
21738
+ devServer.clearResponseTransforms(req);
21173
21739
  output_manager_default.debug(`Failed to complete request to ${req.url}: ${error2}`);
21174
21740
  if (!res.headersSent) {
21175
21741
  devServer.sendError(req, res, requestId, "FUNCTION_INVOCATION_FAILED");
@@ -21361,11 +21927,6 @@ var import_ms5 = __toESM(require_ms(), 1);
21361
21927
  import { setTimeout as setTimeout2 } from "timers/promises";
21362
21928
  import { decodeJwt } from "jose";
21363
21929
  import { performance } from "perf_hooks";
21364
-
21365
- // src/util/env/constants.ts
21366
- var VERCEL_OIDC_TOKEN = "VERCEL_OIDC_TOKEN";
21367
-
21368
- // src/util/env/refresh-oidc-token.ts
21369
21930
  var REFRESH_BEFORE_EXPIRY_MILLIS = getMs(
21370
21931
  (0, import_ms5.default)("15m"),
21371
21932
  process.env.REFRESH_VERCEL_OIDC_TOKEN_BEFORE_EXPIRY_MILLIS