vite-plugin-vercel 11.0.0-beta.20 → 11.0.0-beta.22

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/vite.js +10 -12
  2. package/package.json +2 -2
package/dist/vite.js CHANGED
@@ -546,14 +546,11 @@ function getVcConfig(pluginConfig, filename, options) {
546
546
  //#endregion
547
547
  //#region src/utils/request.ts
548
548
  function getOriginalRequest(request) {
549
- const xNowRouteMatchesHeader = request.headers.get("x-now-route-matches");
549
+ const xOriginalPath = request.headers.get("x-original-path");
550
550
  let newUrl = null;
551
551
  let newRequest = request;
552
- if (typeof xNowRouteMatchesHeader === "string") {
553
- const originalPathBis = new URLSearchParams(xNowRouteMatchesHeader).get("1");
554
- if (originalPathBis) newUrl = new URL(originalPathBis, request.url).toString();
555
- }
556
- if (newUrl) newRequest = new Request(newUrl, {
552
+ if (typeof xOriginalPath === "string") newUrl = new URL(xOriginalPath, request.url).toString();
553
+ if (newUrl && request.url !== newUrl) newRequest = new Request(newUrl, {
557
554
  method: request.method,
558
555
  headers: request.headers,
559
556
  body: request.body,
@@ -762,7 +759,13 @@ function getConfig(pluginConfig) {
762
759
  return r;
763
760
  })),
764
761
  redirects: pluginConfig.redirects ? reorderEnforce(pluginConfig.redirects) : void 0,
765
- headers: pluginConfig.headers
762
+ headers: [{
763
+ source: "/(.*)",
764
+ headers: [{
765
+ key: "x-original-path",
766
+ value: "/$1"
767
+ }]
768
+ }, ...pluginConfig.headers ?? []]
766
769
  });
767
770
  if (error) throw error;
768
771
  if (pluginConfig.config?.routes && pluginConfig.config.routes.length > 0 && !pluginConfig.config.routes.every((r) => "continue" in r && r.continue)) console.warn("Did you forget to add `\"continue\": true` to your routes? See https://vercel.com/docs/build-output-api/v3/configuration#source-route\nIf not, it is discouraged to use `routes` config to override routes. Prefer using `rewrites` and `redirects`.");
@@ -786,7 +789,6 @@ function getConfig(pluginConfig) {
786
789
  routes: buildRoutes
787
790
  }]
788
791
  });
789
- for (const route of cleanRoutes) wrapRouteInParentheses(route);
790
792
  return vercelOutputConfigSchema.parse({
791
793
  version: 3,
792
794
  ...pluginConfig.config,
@@ -794,10 +796,6 @@ function getConfig(pluginConfig) {
794
796
  overrides: { ...pluginConfig.config?.overrides }
795
797
  });
796
798
  }
797
- function wrapRouteInParentheses(route) {
798
- if (!route.src || !route.dest || route.src.match(/^\(.*\)$/) || route.src.match(/^\^\(.*\)\$$/)) return;
799
- route.src = `(${route.src})`;
800
- }
801
799
 
802
800
  //#endregion
803
801
  //#region src/utils/const.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vercel",
3
- "version": "11.0.0-beta.20",
3
+ "version": "11.0.0-beta.22",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@manypkg/find-root": "^3.1.0",
36
- "@universal-deploy/store": "^0.1.3",
36
+ "@universal-deploy/store": "^0.1.4",
37
37
  "@universal-middleware/core": "^0.4.13",
38
38
  "@universal-middleware/vercel": "^0.4.29",
39
39
  "@vercel/build-utils": "^13.2.3",