@taskmark/ui 0.2.2 → 0.2.5
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/README.md +23 -7
- package/app/api/taskmark-reload/route.ts +103 -0
- package/app/board/page.tsx +6 -4
- package/app/globals.css +17 -1
- package/app/layout.tsx +2 -0
- package/bin/lib/static-preview.mjs +110 -0
- package/bin/lib/watch-board-markdown.mjs +65 -0
- package/bin/taskmark.js +254 -46
- package/components/board/app-bar.tsx +31 -34
- package/components/board/board-dev-reloader.tsx +49 -0
- package/components/board/epic-list.tsx +2 -4
- package/components/board/markdown-content.tsx +1 -2
- package/components/board/overall-work-items-list.tsx +2 -1
- package/components/board/static-board-app.tsx +0 -1
- package/components/board/story-list.tsx +2 -1
- package/components/board/task-list.tsx +2 -1
- package/components/board/work-item-sheet.tsx +15 -2
- package/components/board/work-items-list.tsx +2 -2
- package/components/setup/setup-wizard.tsx +2 -6
- package/dist/prod-next/BUILD_ID +1 -0
- package/dist/{standalone/.next → prod-next}/app-path-routes-manifest.json +3 -2
- package/dist/{standalone/.next → prod-next}/build-manifest.json +3 -3
- package/dist/prod-next/export-marker.json +6 -0
- package/dist/prod-next/images-manifest.json +68 -0
- package/dist/prod-next/next-minimal-server.js.nft.json +1 -0
- package/dist/prod-next/next-server.js.nft.json +1 -0
- package/dist/{standalone/.next → prod-next}/prerender-manifest.json +3 -3
- package/dist/{standalone/.next → prod-next}/react-loadable-manifest.json +2 -2
- package/dist/prod-next/required-server-files.js +337 -0
- package/dist/{standalone/.next → prod-next}/required-server-files.json +0 -7
- package/dist/{standalone/.next → prod-next}/routes-manifest.json +6 -0
- package/dist/prod-next/server/app/_global-error/page.js +32 -0
- package/dist/prod-next/server/app/_global-error/page.js.nft.json +1 -0
- package/dist/prod-next/server/app/_global-error/page_client-reference-manifest.js +1 -0
- package/dist/{standalone/.next → prod-next}/server/app/_global-error.html +1 -1
- package/dist/{standalone/.next → prod-next}/server/app/_global-error.rsc +1 -1
- package/dist/{standalone/.next → prod-next}/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/{standalone/.next → prod-next}/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/{standalone/.next → prod-next}/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/{standalone/.next → prod-next}/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/{standalone/.next → prod-next}/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/{standalone/.next → prod-next}/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/prod-next/server/app/_not-found/page.js +2 -0
- package/dist/prod-next/server/app/_not-found/page.js.nft.json +1 -0
- package/dist/prod-next/server/app/_not-found/page_client-reference-manifest.js +1 -0
- package/dist/prod-next/server/app/_not-found.html +1 -0
- package/dist/prod-next/server/app/_not-found.rsc +21 -0
- package/dist/prod-next/server/app/_not-found.segments/_full.segment.rsc +21 -0
- package/dist/{standalone/.next → prod-next}/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/prod-next/server/app/_not-found.segments/_index.segment.rsc +8 -0
- package/dist/{standalone/.next → prod-next}/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/{standalone/.next → prod-next}/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/{standalone/.next → prod-next}/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/dist/prod-next/server/app/api/taskmark-reload/route.js +1 -0
- package/dist/prod-next/server/app/api/taskmark-reload/route.js.nft.json +1 -0
- package/dist/prod-next/server/app/api/taskmark-reload/route_client-reference-manifest.js +1 -0
- package/dist/prod-next/server/app/board/page.js +50 -0
- package/dist/prod-next/server/app/board/page.js.nft.json +1 -0
- package/dist/prod-next/server/app/board/page_client-reference-manifest.js +1 -0
- package/dist/{standalone/.next → prod-next}/server/app/favicon.ico/route.js +1 -1
- package/dist/prod-next/server/app/favicon.ico/route.js.nft.json +1 -0
- package/dist/prod-next/server/app/page.js +2 -0
- package/dist/prod-next/server/app/page.js.nft.json +1 -0
- package/dist/prod-next/server/app/page_client-reference-manifest.js +1 -0
- package/dist/prod-next/server/app/setup/page.js +2 -0
- package/dist/prod-next/server/app/setup/page.js.nft.json +1 -0
- package/dist/prod-next/server/app/setup/page_client-reference-manifest.js +1 -0
- package/dist/{standalone/.next → prod-next}/server/app-paths-manifest.json +3 -2
- package/dist/{standalone/.next → prod-next}/server/chunks/319.js +1 -1
- package/dist/{standalone/.next → prod-next}/server/chunks/490.js +1 -1
- package/dist/prod-next/server/chunks/57.js +19 -0
- package/dist/prod-next/server/chunks/616.js +1 -0
- package/dist/prod-next/server/chunks/708.js +1 -0
- package/dist/prod-next/server/chunks/724.js +1 -0
- package/dist/{standalone/.next/server/chunks/445.js → prod-next/server/chunks/741.js} +2 -2
- package/dist/prod-next/server/functions-config-manifest.json +6 -0
- package/dist/prod-next/server/interception-route-rewrite-manifest.js +1 -0
- package/dist/{standalone/.next → prod-next}/server/middleware-build-manifest.js +1 -1
- package/dist/prod-next/server/middleware-react-loadable-manifest.js +1 -0
- package/dist/prod-next/server/pages/404.html +1 -0
- package/dist/{standalone/.next → prod-next}/server/pages/500.html +1 -1
- package/dist/prod-next/server/server-reference-manifest.js +1 -0
- package/dist/prod-next/server/server-reference-manifest.json +1 -0
- package/dist/prod-next/static/chunks/51.e9139a9ea6eb36b9.js +1 -0
- package/dist/{standalone/.next/static/chunks/781-f9f201ddc8c8591a.js → prod-next/static/chunks/613-6f794154d28bb75a.js} +1 -1
- package/dist/prod-next/static/chunks/app/_global-error/page-d34451c04262dd7d.js +1 -0
- package/dist/prod-next/static/chunks/app/api/taskmark-reload/route-d34451c04262dd7d.js +1 -0
- package/dist/prod-next/static/chunks/app/board/page-cd1d9be0c0127225.js +1 -0
- package/dist/prod-next/static/chunks/app/layout-856e8a282e69e7d0.js +1 -0
- package/dist/prod-next/static/chunks/app/page-d34451c04262dd7d.js +1 -0
- package/dist/prod-next/static/chunks/app/setup/page-c3003359e8becc84.js +1 -0
- package/dist/prod-next/static/chunks/next/dist/client/components/builtin/app-error-d34451c04262dd7d.js +1 -0
- package/dist/prod-next/static/chunks/next/dist/client/components/builtin/forbidden-d34451c04262dd7d.js +1 -0
- package/dist/prod-next/static/chunks/next/dist/client/components/builtin/not-found-d34451c04262dd7d.js +1 -0
- package/dist/prod-next/static/chunks/next/dist/client/components/builtin/unauthorized-d34451c04262dd7d.js +1 -0
- package/dist/prod-next/static/chunks/webpack-bfe8992962004e2b.js +1 -0
- package/dist/prod-next/static/css/2e6ec4c80894e3c0.css +1 -0
- package/dist/prod-next/static/wbcgYS3Jw87KqhnA9ttOL/_buildManifest.js +1 -0
- package/dist/public/taskmark-snapshot.json +1 -0
- package/lib/display-path.ts +6 -0
- package/lib/taskmark/dev-reload-token.ts +5 -0
- package/lib/taskmark/project-label.ts +3 -2
- package/lib/taskmark/validate.ts +4 -4
- package/next.config.ts +3 -8
- package/package.json +6 -4
- package/public/taskmark-snapshot.json +1 -1
- package/scripts/build-static.mjs +10 -1
- package/scripts/prepare-standalone.mjs +53 -20
- package/dist/standalone/.next/BUILD_ID +0 -1
- package/dist/standalone/.next/server/app/_global-error/page.js +0 -32
- package/dist/standalone/.next/server/app/_global-error/page.js.nft.json +0 -1
- package/dist/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +0 -1
- package/dist/standalone/.next/server/app/_not-found/page.js +0 -2
- package/dist/standalone/.next/server/app/_not-found/page.js.nft.json +0 -1
- package/dist/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
- package/dist/standalone/.next/server/app/_not-found.html +0 -1
- package/dist/standalone/.next/server/app/_not-found.rsc +0 -20
- package/dist/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +0 -20
- package/dist/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +0 -7
- package/dist/standalone/.next/server/app/board/page.js +0 -50
- package/dist/standalone/.next/server/app/board/page.js.nft.json +0 -1
- package/dist/standalone/.next/server/app/board/page_client-reference-manifest.js +0 -1
- package/dist/standalone/.next/server/app/favicon.ico/route.js.nft.json +0 -1
- package/dist/standalone/.next/server/app/page.js +0 -2
- package/dist/standalone/.next/server/app/page.js.nft.json +0 -1
- package/dist/standalone/.next/server/app/page_client-reference-manifest.js +0 -1
- package/dist/standalone/.next/server/app/setup/page.js +0 -2
- package/dist/standalone/.next/server/app/setup/page.js.nft.json +0 -1
- package/dist/standalone/.next/server/app/setup/page_client-reference-manifest.js +0 -1
- package/dist/standalone/.next/server/chunks/57.js +0 -19
- package/dist/standalone/.next/server/chunks/570.js +0 -1
- package/dist/standalone/.next/server/chunks/600.js +0 -1
- package/dist/standalone/.next/server/chunks/666.js +0 -1
- package/dist/standalone/.next/server/functions-config-manifest.json +0 -4
- package/dist/standalone/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/dist/standalone/.next/server/pages/404.html +0 -1
- package/dist/standalone/.next/server/server-reference-manifest.js +0 -1
- package/dist/standalone/.next/server/server-reference-manifest.json +0 -1
- package/dist/standalone/.next/static/O83kNzYUmJlkfw7SS-SsU/_buildManifest.js +0 -1
- package/dist/standalone/.next/static/chunks/826.92750d8ed3a55429.js +0 -1
- package/dist/standalone/.next/static/chunks/app/_global-error/page-82d456ade9f47021.js +0 -1
- package/dist/standalone/.next/static/chunks/app/board/page-f609a854d76933c2.js +0 -1
- package/dist/standalone/.next/static/chunks/app/layout-3745e06d87691845.js +0 -1
- package/dist/standalone/.next/static/chunks/app/page-82d456ade9f47021.js +0 -1
- package/dist/standalone/.next/static/chunks/app/setup/page-acaffda2083bf4d0.js +0 -1
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-82d456ade9f47021.js +0 -1
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-82d456ade9f47021.js +0 -1
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-82d456ade9f47021.js +0 -1
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-82d456ade9f47021.js +0 -1
- package/dist/standalone/.next/static/chunks/webpack-f181688592aeb1f6.js +0 -1
- package/dist/standalone/.next/static/css/7af268deac5c5edb.css +0 -1
- package/dist/standalone/node_modules/next/dist/compiled/jest-worker/processChild.js +0 -1
- package/dist/standalone/node_modules/next/dist/compiled/jest-worker/threadChild.js +0 -1
- package/dist/standalone/node_modules/next/dist/server/lib/start-server.js +0 -494
- package/dist/standalone/node_modules/next/dist/server/next-server.js +0 -1429
- package/dist/standalone/node_modules/next/dist/server/next.js +0 -455
- package/dist/standalone/node_modules/next/dist/server/require-hook.js +0 -82
- package/dist/standalone/node_modules/next/dist/server/route-modules/app-page/module.compiled.js +0 -36
- package/dist/standalone/node_modules/next/dist/server/route-modules/pages/module.compiled.js +0 -20
- package/dist/standalone/node_modules/styled-jsx/index.js +0 -1
- package/dist/standalone/node_modules/styled-jsx/package.json +0 -132
- package/dist/standalone/node_modules/styled-jsx/style.js +0 -1
- package/dist/standalone/package.json +0 -76
- package/dist/standalone/public/taskmark-snapshot.json +0 -1
- package/dist/standalone/server.js +0 -44
- /package/dist/{standalone/.next → prod-next}/package.json +0 -0
- /package/dist/{standalone/.next → prod-next}/server/app/_global-error.meta +0 -0
- /package/dist/{standalone/.next → prod-next}/server/app/_not-found.meta +0 -0
- /package/dist/{standalone/.next → prod-next}/server/app/favicon.ico.body +0 -0
- /package/dist/{standalone/.next → prod-next}/server/app/favicon.ico.meta +0 -0
- /package/dist/{standalone/.next → prod-next}/server/chunks/318.js +0 -0
- /package/dist/{standalone/.next → prod-next}/server/middleware-manifest.json +0 -0
- /package/dist/{standalone/.next → prod-next}/server/next-font-manifest.js +0 -0
- /package/dist/{standalone/.next → prod-next}/server/next-font-manifest.json +0 -0
- /package/dist/{standalone/.next → prod-next}/server/pages-manifest.json +0 -0
- /package/dist/{standalone/.next → prod-next}/server/prefetch-hints.json +0 -0
- /package/dist/{standalone/.next → prod-next}/server/webpack-runtime.js +0 -0
- /package/dist/{standalone/.next → prod-next}/static/chunks/4bd1b696-deb4a0a1da1923b0.js +0 -0
- /package/dist/{standalone/.next → prod-next}/static/chunks/669-8103441c67b185da.js +0 -0
- /package/dist/{standalone/.next → prod-next}/static/chunks/701-df3ee5f1cf837b1a.js +0 -0
- /package/dist/{standalone/.next → prod-next}/static/chunks/794-25668765560cb197.js +0 -0
- /package/dist/{standalone/.next → prod-next}/static/chunks/app/_not-found/page-0b3785af737e7968.js +0 -0
- /package/dist/{standalone/.next → prod-next}/static/chunks/framework-b29f9083d3cda3b2.js +0 -0
- /package/dist/{standalone/.next → prod-next}/static/chunks/main-app-bfb36455d24b3e5a.js +0 -0
- /package/dist/{standalone/.next → prod-next}/static/chunks/main-bb33c46a9c25dee8.js +0 -0
- /package/dist/{standalone/.next → prod-next}/static/chunks/next/dist/client/components/builtin/global-error-dc53ab29e0491fe4.js +0 -0
- /package/dist/{standalone/.next → prod-next}/static/chunks/polyfills-42372ed130431b0a.js +0 -0
- /package/dist/{standalone/.next → prod-next}/static/css/c593627ceef17a4b.css +0 -0
- /package/dist/{standalone/.next → prod-next}/static/media/36966cca54120369-s.p.woff2 +0 -0
- /package/dist/{standalone/.next → prod-next}/static/media/982ceffe7b733b3b-s.p.woff2 +0 -0
- /package/dist/{standalone/.next → prod-next}/static/media/b7387a63dd068245-s.woff2 +0 -0
- /package/dist/{standalone/.next → prod-next}/static/media/b8bfb68ab9ab617c-s.woff2 +0 -0
- /package/dist/{standalone/.next → prod-next}/static/media/e1aab0933260df4d-s.woff2 +0 -0
- /package/dist/{standalone/.next/static/O83kNzYUmJlkfw7SS-SsU → prod-next/static/wbcgYS3Jw87KqhnA9ttOL}/_ssgManifest.js +0 -0
- /package/dist/{standalone/public → public}/apple-touch-icon.png +0 -0
- /package/dist/{standalone/public → public}/favicon-96x96.png +0 -0
- /package/dist/{standalone/public → public}/favicon.ico +0 -0
- /package/dist/{standalone/public → public}/favicon.svg +0 -0
- /package/dist/{standalone/public → public}/file.svg +0 -0
- /package/dist/{standalone/public → public}/globe.svg +0 -0
- /package/dist/{standalone/public → public}/next.svg +0 -0
- /package/dist/{standalone/public → public}/og/og-default.png +0 -0
- /package/dist/{standalone/public → public}/site.webmanifest +0 -0
- /package/dist/{standalone/public → public}/tm_dark.png +0 -0
- /package/dist/{standalone/public → public}/tm_light.png +0 -0
- /package/dist/{standalone/public → public}/vercel.svg +0 -0
- /package/dist/{standalone/public → public}/web-app-manifest-192x192.png +0 -0
- /package/dist/{standalone/public → public}/web-app-manifest-512x512.png +0 -0
- /package/dist/{standalone/public → public}/window.svg +0 -0
|
@@ -1,1429 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return NextNodeServer;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
0 && __export(require("./base-server"));
|
|
12
|
-
require("./node-environment");
|
|
13
|
-
require("./require-hook");
|
|
14
|
-
require("./node-polyfill-crypto");
|
|
15
|
-
const _utils = require("../shared/lib/utils");
|
|
16
|
-
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
17
|
-
const _path = require("path");
|
|
18
|
-
const _routematcher = require("../shared/lib/router/utils/route-matcher");
|
|
19
|
-
const _requestmeta = require("./request-meta");
|
|
20
|
-
const _constants = require("../shared/lib/constants");
|
|
21
|
-
const _findpagesdir = require("../lib/find-pages-dir");
|
|
22
|
-
const _node = require("./base-http/node");
|
|
23
|
-
const _sendpayload = require("./send-payload");
|
|
24
|
-
const _parseurl = require("../shared/lib/router/utils/parse-url");
|
|
25
|
-
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../build/output/log"));
|
|
26
|
-
const _baseserver = /*#__PURE__*/ _interop_require_default(_export_star(require("./base-server"), exports));
|
|
27
|
-
const _require = require("./require");
|
|
28
|
-
const _denormalizepagepath = require("../shared/lib/page-path/denormalize-page-path");
|
|
29
|
-
const _normalizepagepath = require("../shared/lib/page-path/normalize-page-path");
|
|
30
|
-
const _loadcomponents = require("./load-components");
|
|
31
|
-
const _iserror = /*#__PURE__*/ _interop_require_wildcard(require("../lib/is-error"));
|
|
32
|
-
const _utils1 = require("./web/utils");
|
|
33
|
-
const _middlewareroutematcher = require("../shared/lib/router/utils/middleware-route-matcher");
|
|
34
|
-
const _env = require("@next/env");
|
|
35
|
-
const _querystring = require("../shared/lib/router/utils/querystring");
|
|
36
|
-
const _removetrailingslash = require("../shared/lib/router/utils/remove-trailing-slash");
|
|
37
|
-
const _getnextpathnameinfo = require("../shared/lib/router/utils/get-next-pathname-info");
|
|
38
|
-
const _bodystreams = require("./body-streams");
|
|
39
|
-
const _apiutils = require("./api-utils");
|
|
40
|
-
const _responsecache = /*#__PURE__*/ _interop_require_wildcard(require("./response-cache"));
|
|
41
|
-
const _incrementalcache = require("./lib/incremental-cache");
|
|
42
|
-
const _apppaths = require("../shared/lib/router/utils/app-paths");
|
|
43
|
-
const _setuphttpagentenv = require("./setup-http-agent-env");
|
|
44
|
-
const _pagesapiroutematch = require("./route-matches/pages-api-route-match");
|
|
45
|
-
const _tracer = require("./lib/trace/tracer");
|
|
46
|
-
const _constants1 = require("./lib/trace/constants");
|
|
47
|
-
const _nodefsmethods = require("./lib/node-fs-methods");
|
|
48
|
-
const _routeregex = require("../shared/lib/router/utils/route-regex");
|
|
49
|
-
const _pipereadable = require("./pipe-readable");
|
|
50
|
-
const _mockrequest = require("./lib/mock-request");
|
|
51
|
-
const _approuterheaders = require("../client/components/app-router-headers");
|
|
52
|
-
const _nextrequest = require("./web/spec-extension/adapters/next-request");
|
|
53
|
-
const _loadmanifestexternal = require("./load-manifest.external");
|
|
54
|
-
const _modulerender = require("./route-modules/app-page/module.render");
|
|
55
|
-
const _modulerender1 = require("./route-modules/pages/module.render");
|
|
56
|
-
const _interopdefault = require("../lib/interop-default");
|
|
57
|
-
const _formatdynamicimportpath = require("../lib/format-dynamic-import-path");
|
|
58
|
-
const _isinterceptionrouterewrite = require("../lib/is-interception-route-rewrite");
|
|
59
|
-
const _routekind = require("./route-kind");
|
|
60
|
-
const _invarianterror = require("../shared/lib/invariant-error");
|
|
61
|
-
const _awaiter = require("./after/awaiter");
|
|
62
|
-
const _asynccallbackset = require("./lib/async-callback-set");
|
|
63
|
-
const _handlers = require("./use-cache/handlers");
|
|
64
|
-
const _staticenv = require("../lib/static-env");
|
|
65
|
-
const _nodemoduleloader = require("./lib/module-loader/node-module-loader");
|
|
66
|
-
const _nofallbackerrorexternal = require("../shared/lib/no-fallback-error.external");
|
|
67
|
-
const _instrumentationglobalsexternal = require("./lib/router-utils/instrumentation-globals.external");
|
|
68
|
-
const _routerservercontext = require("./lib/router-utils/router-server-context");
|
|
69
|
-
const _globalbehaviors = require("./node-environment-extensions/global-behaviors");
|
|
70
|
-
const _processerrorhandlers = require("./node-environment-extensions/process-error-handlers");
|
|
71
|
-
function _export_star(from, to) {
|
|
72
|
-
Object.keys(from).forEach(function(k) {
|
|
73
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
74
|
-
Object.defineProperty(to, k, {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: function() {
|
|
77
|
-
return from[k];
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
return from;
|
|
83
|
-
}
|
|
84
|
-
function _interop_require_default(obj) {
|
|
85
|
-
return obj && obj.__esModule ? obj : {
|
|
86
|
-
default: obj
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
90
|
-
if (typeof WeakMap !== "function") return null;
|
|
91
|
-
var cacheBabelInterop = new WeakMap();
|
|
92
|
-
var cacheNodeInterop = new WeakMap();
|
|
93
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
94
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
95
|
-
})(nodeInterop);
|
|
96
|
-
}
|
|
97
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
98
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
99
|
-
return obj;
|
|
100
|
-
}
|
|
101
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
102
|
-
return {
|
|
103
|
-
default: obj
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
107
|
-
if (cache && cache.has(obj)) {
|
|
108
|
-
return cache.get(obj);
|
|
109
|
-
}
|
|
110
|
-
var newObj = {
|
|
111
|
-
__proto__: null
|
|
112
|
-
};
|
|
113
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
114
|
-
for(var key in obj){
|
|
115
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
116
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
117
|
-
if (desc && (desc.get || desc.set)) {
|
|
118
|
-
Object.defineProperty(newObj, key, desc);
|
|
119
|
-
} else {
|
|
120
|
-
newObj[key] = obj[key];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
newObj.default = obj;
|
|
125
|
-
if (cache) {
|
|
126
|
-
cache.set(obj, newObj);
|
|
127
|
-
}
|
|
128
|
-
return newObj;
|
|
129
|
-
}
|
|
130
|
-
// For module that can be both CJS or ESM
|
|
131
|
-
const dynamicImportEsmDefault = process.env.NEXT_MINIMAL ? (id)=>import(/* webpackIgnore: true */ id).then((mod)=>mod.default || mod) : (id)=>import(id).then((mod)=>mod.default || mod);
|
|
132
|
-
const MiddlewareMatcherCache = new WeakMap();
|
|
133
|
-
function getMiddlewareMatcher(info) {
|
|
134
|
-
const stored = MiddlewareMatcherCache.get(info);
|
|
135
|
-
if (stored) {
|
|
136
|
-
return stored;
|
|
137
|
-
}
|
|
138
|
-
if (!Array.isArray(info.matchers)) {
|
|
139
|
-
throw Object.defineProperty(new Error(`Invariant: invalid matchers for middleware ${JSON.stringify(info)}`), "__NEXT_ERROR_CODE", {
|
|
140
|
-
value: "E257",
|
|
141
|
-
enumerable: false,
|
|
142
|
-
configurable: true
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
const matcher = (0, _middlewareroutematcher.getMiddlewareRouteMatcher)(info.matchers);
|
|
146
|
-
MiddlewareMatcherCache.set(info, matcher);
|
|
147
|
-
return matcher;
|
|
148
|
-
}
|
|
149
|
-
class NextNodeServer extends _baseserver.default {
|
|
150
|
-
constructor(options){
|
|
151
|
-
var _options_conf_experimental_sri, _options_conf_experimental, _options_conf_experimental1;
|
|
152
|
-
// Initialize super class
|
|
153
|
-
super(options), this.cleanupListeners = new _asynccallbackset.AsyncCallbackSet(), this.handleNextImageRequest = async (req, res, parsedUrl)=>{
|
|
154
|
-
if (!parsedUrl.pathname || !parsedUrl.pathname.startsWith('/_next/image')) {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
// Ignore if its a middleware request
|
|
158
|
-
if ((0, _requestmeta.getRequestMeta)(req, 'middlewareInvoke')) {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
if (this.minimalMode || this.nextConfig.output === 'export' || process.env.NEXT_MINIMAL) {
|
|
162
|
-
res.statusCode = 400;
|
|
163
|
-
res.body('Bad Request').send();
|
|
164
|
-
return true;
|
|
165
|
-
// the `else` branch is needed for tree-shaking
|
|
166
|
-
} else {
|
|
167
|
-
const { ImageOptimizerCache } = require('./image-optimizer');
|
|
168
|
-
// Load custom cache handler if configured and opt-in via images.customCacheHandler
|
|
169
|
-
// Cache the handler instance to preserve state across requests
|
|
170
|
-
if (!this.imageCacheHandler && this.nextConfig.images.customCacheHandler) {
|
|
171
|
-
const { cacheHandler } = this.nextConfig;
|
|
172
|
-
if (cacheHandler) {
|
|
173
|
-
const CacheHandler = (0, _interopdefault.interopDefault)(await dynamicImportEsmDefault((0, _formatdynamicimportpath.formatDynamicImportPath)(this.distDir, cacheHandler)));
|
|
174
|
-
this.imageCacheHandler = new CacheHandler({
|
|
175
|
-
dev: !!this.dev,
|
|
176
|
-
flushToDisk: this.nextConfig.experimental.isrFlushToDisk,
|
|
177
|
-
serverDistDir: this.serverDistDir,
|
|
178
|
-
maxMemoryCacheSize: this.nextConfig.cacheMaxMemorySize,
|
|
179
|
-
revalidatedTags: [],
|
|
180
|
-
_requestHeaders: {}
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const imageOptimizerCache = new ImageOptimizerCache({
|
|
185
|
-
distDir: this.distDir,
|
|
186
|
-
nextConfig: this.nextConfig,
|
|
187
|
-
cacheHandler: this.imageCacheHandler
|
|
188
|
-
});
|
|
189
|
-
const { sendResponse, ImageError } = require('./image-optimizer');
|
|
190
|
-
if (!this.imageResponseCache) {
|
|
191
|
-
throw Object.defineProperty(new Error('invariant image optimizer cache was not initialized'), "__NEXT_ERROR_CODE", {
|
|
192
|
-
value: "E160",
|
|
193
|
-
enumerable: false,
|
|
194
|
-
configurable: true
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
const imagesConfig = this.nextConfig.images;
|
|
198
|
-
if (imagesConfig.loader !== 'default' || imagesConfig.unoptimized) {
|
|
199
|
-
await this.render404(req, res);
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
const paramsResult = ImageOptimizerCache.validateParams(req.originalRequest, parsedUrl.query, this.nextConfig, !!this.dev);
|
|
203
|
-
if ('errorMessage' in paramsResult) {
|
|
204
|
-
res.statusCode = 400;
|
|
205
|
-
res.body(paramsResult.errorMessage).send();
|
|
206
|
-
return true;
|
|
207
|
-
}
|
|
208
|
-
const cacheKey = ImageOptimizerCache.getCacheKey(paramsResult);
|
|
209
|
-
try {
|
|
210
|
-
var _cacheEntry_value, _cacheEntry_cacheControl;
|
|
211
|
-
const { getExtension } = require('./serve-static');
|
|
212
|
-
const cacheEntry = await this.imageResponseCache.get(cacheKey, async ({ previousCacheEntry })=>{
|
|
213
|
-
const { buffer, contentType, maxAge, upstreamEtag, etag } = await this.imageOptimizer(req, res, paramsResult, previousCacheEntry);
|
|
214
|
-
return {
|
|
215
|
-
value: {
|
|
216
|
-
kind: _responsecache.CachedRouteKind.IMAGE,
|
|
217
|
-
buffer,
|
|
218
|
-
etag,
|
|
219
|
-
extension: getExtension(contentType),
|
|
220
|
-
upstreamEtag
|
|
221
|
-
},
|
|
222
|
-
cacheControl: {
|
|
223
|
-
revalidate: maxAge,
|
|
224
|
-
expire: undefined
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
}, {
|
|
228
|
-
routeKind: _routekind.RouteKind.IMAGE,
|
|
229
|
-
incrementalCache: imageOptimizerCache,
|
|
230
|
-
isFallback: false
|
|
231
|
-
});
|
|
232
|
-
if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== _responsecache.CachedRouteKind.IMAGE) {
|
|
233
|
-
throw Object.defineProperty(new Error('invariant did not get entry from image response cache'), "__NEXT_ERROR_CODE", {
|
|
234
|
-
value: "E518",
|
|
235
|
-
enumerable: false,
|
|
236
|
-
configurable: true
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
sendResponse(req.originalRequest, res.originalResponse, paramsResult.href, cacheEntry.value.extension, cacheEntry.value.buffer, cacheEntry.value.etag, paramsResult.isStatic, cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT', imagesConfig, ((_cacheEntry_cacheControl = cacheEntry.cacheControl) == null ? void 0 : _cacheEntry_cacheControl.revalidate) || 0, Boolean(this.dev));
|
|
240
|
-
return true;
|
|
241
|
-
} catch (err) {
|
|
242
|
-
if (err instanceof ImageError) {
|
|
243
|
-
res.statusCode = err.statusCode;
|
|
244
|
-
res.body(err.message).send();
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
throw err;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}, this.handleCatchallRenderRequest = async (req, res, parsedUrl)=>{
|
|
251
|
-
let { pathname, query } = parsedUrl;
|
|
252
|
-
if (!pathname) {
|
|
253
|
-
throw Object.defineProperty(new Error('Invariant: pathname is undefined'), "__NEXT_ERROR_CODE", {
|
|
254
|
-
value: "E409",
|
|
255
|
-
enumerable: false,
|
|
256
|
-
configurable: true
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
// When in minimal mode we do not bubble the fallback as the
|
|
260
|
-
// router-server is not present to handle the error
|
|
261
|
-
(0, _requestmeta.addRequestMeta)(req, 'bubbleNoFallback', this.minimalMode ? undefined : true);
|
|
262
|
-
// This is needed to expose render404 and nextConfig
|
|
263
|
-
// for environments without router-server
|
|
264
|
-
if (!_routerservercontext.routerServerGlobal[_routerservercontext.RouterServerContextSymbol]) {
|
|
265
|
-
_routerservercontext.routerServerGlobal[_routerservercontext.RouterServerContextSymbol] = {};
|
|
266
|
-
}
|
|
267
|
-
const relativeProjectDir = (0, _path.relative)(process.cwd(), this.dir);
|
|
268
|
-
const existingServerContext = _routerservercontext.routerServerGlobal[_routerservercontext.RouterServerContextSymbol][relativeProjectDir];
|
|
269
|
-
if (!existingServerContext) {
|
|
270
|
-
_routerservercontext.routerServerGlobal[_routerservercontext.RouterServerContextSymbol][relativeProjectDir] = {
|
|
271
|
-
render404: this.render404.bind(this)
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
_routerservercontext.routerServerGlobal[_routerservercontext.RouterServerContextSymbol][relativeProjectDir].nextConfig = this.nextConfig;
|
|
275
|
-
_routerservercontext.routerServerGlobal[_routerservercontext.RouterServerContextSymbol][relativeProjectDir].isWrappedByNextServer = true;
|
|
276
|
-
try {
|
|
277
|
-
var _this_i18nProvider;
|
|
278
|
-
// next.js core assumes page path without trailing slash
|
|
279
|
-
pathname = (0, _removetrailingslash.removeTrailingSlash)(pathname);
|
|
280
|
-
const options = {
|
|
281
|
-
i18n: (_this_i18nProvider = this.i18nProvider) == null ? void 0 : _this_i18nProvider.fromRequest(req, pathname)
|
|
282
|
-
};
|
|
283
|
-
const match = await this.matchers.match(pathname, options);
|
|
284
|
-
// If we don't have a match, try to render it anyways.
|
|
285
|
-
if (!match) {
|
|
286
|
-
await this.render(req, res, pathname, query, parsedUrl, true);
|
|
287
|
-
return true;
|
|
288
|
-
}
|
|
289
|
-
// Add the match to the request so we don't have to re-run the matcher
|
|
290
|
-
// for the same request.
|
|
291
|
-
(0, _requestmeta.addRequestMeta)(req, 'match', match);
|
|
292
|
-
// TODO-APP: move this to a route handler
|
|
293
|
-
const edgeFunctionsPages = this.getEdgeFunctionsPages();
|
|
294
|
-
for (const edgeFunctionsPage of edgeFunctionsPages){
|
|
295
|
-
// If the page doesn't match the edge function page, skip it.
|
|
296
|
-
if (edgeFunctionsPage !== match.definition.page) continue;
|
|
297
|
-
if (this.nextConfig.output === 'export') {
|
|
298
|
-
await this.render404(req, res, parsedUrl);
|
|
299
|
-
return true;
|
|
300
|
-
}
|
|
301
|
-
delete query[_approuterheaders.NEXT_RSC_UNION_QUERY];
|
|
302
|
-
// If we handled the request, we can return early.
|
|
303
|
-
// For api routes edge runtime
|
|
304
|
-
try {
|
|
305
|
-
const handled = await this.runEdgeFunction({
|
|
306
|
-
req,
|
|
307
|
-
res,
|
|
308
|
-
query,
|
|
309
|
-
params: match.params,
|
|
310
|
-
page: match.definition.page,
|
|
311
|
-
match,
|
|
312
|
-
appPaths: null
|
|
313
|
-
});
|
|
314
|
-
if (handled) return true;
|
|
315
|
-
} catch (apiError) {
|
|
316
|
-
const silenceLog = false;
|
|
317
|
-
await this.instrumentationOnRequestError(apiError, req, {
|
|
318
|
-
routePath: match.definition.page,
|
|
319
|
-
routerKind: 'Pages Router',
|
|
320
|
-
routeType: 'route',
|
|
321
|
-
// Edge runtime does not support ISR
|
|
322
|
-
revalidateReason: undefined
|
|
323
|
-
}, silenceLog);
|
|
324
|
-
throw apiError;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
// If the route was detected as being a Pages API route, then handle
|
|
328
|
-
// it.
|
|
329
|
-
// TODO: move this behavior into a route handler.
|
|
330
|
-
if ((0, _pagesapiroutematch.isPagesAPIRouteMatch)(match)) {
|
|
331
|
-
if (this.nextConfig.output === 'export') {
|
|
332
|
-
await this.render404(req, res, parsedUrl);
|
|
333
|
-
return true;
|
|
334
|
-
}
|
|
335
|
-
const handled = await this.handleApiRequest(req, res, query, match);
|
|
336
|
-
if (handled) return true;
|
|
337
|
-
}
|
|
338
|
-
await this.render(req, res, pathname, query, parsedUrl, true);
|
|
339
|
-
return true;
|
|
340
|
-
} catch (err) {
|
|
341
|
-
if (err instanceof _nofallbackerrorexternal.NoFallbackError) {
|
|
342
|
-
throw err;
|
|
343
|
-
}
|
|
344
|
-
try {
|
|
345
|
-
if (this.dev) {
|
|
346
|
-
const { formatServerError } = require('../lib/format-server-error');
|
|
347
|
-
formatServerError(err);
|
|
348
|
-
this.logErrorWithOriginalStack(err);
|
|
349
|
-
} else {
|
|
350
|
-
this.logError(err);
|
|
351
|
-
}
|
|
352
|
-
res.statusCode = 500;
|
|
353
|
-
await this.renderError(err, req, res, pathname, query);
|
|
354
|
-
return true;
|
|
355
|
-
} catch {}
|
|
356
|
-
throw err;
|
|
357
|
-
}
|
|
358
|
-
}, this.handleCatchallMiddlewareRequest = async (req, res, parsed)=>{
|
|
359
|
-
const isMiddlewareInvoke = (0, _requestmeta.getRequestMeta)(req, 'middlewareInvoke');
|
|
360
|
-
if (!isMiddlewareInvoke) {
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
const handleFinished = ()=>{
|
|
364
|
-
(0, _requestmeta.addRequestMeta)(req, 'middlewareInvoke', true);
|
|
365
|
-
res.body('').send();
|
|
366
|
-
return true;
|
|
367
|
-
};
|
|
368
|
-
const middleware = await this.getMiddleware();
|
|
369
|
-
if (!middleware) {
|
|
370
|
-
return handleFinished();
|
|
371
|
-
}
|
|
372
|
-
const initUrl = (0, _requestmeta.getRequestMeta)(req, 'initURL');
|
|
373
|
-
const parsedUrl = (0, _parseurl.parseUrl)(initUrl);
|
|
374
|
-
const pathnameInfo = (0, _getnextpathnameinfo.getNextPathnameInfo)(parsedUrl.pathname, {
|
|
375
|
-
nextConfig: this.nextConfig,
|
|
376
|
-
i18nProvider: this.i18nProvider
|
|
377
|
-
});
|
|
378
|
-
parsedUrl.pathname = pathnameInfo.pathname;
|
|
379
|
-
const normalizedPathname = (0, _removetrailingslash.removeTrailingSlash)(parsed.pathname || '');
|
|
380
|
-
let maybeDecodedPathname = normalizedPathname;
|
|
381
|
-
try {
|
|
382
|
-
maybeDecodedPathname = decodeURIComponent(normalizedPathname);
|
|
383
|
-
} catch {
|
|
384
|
-
/* non-fatal we can't decode so can't match it */ }
|
|
385
|
-
if (!(middleware.match(normalizedPathname, req, parsedUrl.query) || middleware.match(maybeDecodedPathname, req, parsedUrl.query))) {
|
|
386
|
-
return handleFinished();
|
|
387
|
-
}
|
|
388
|
-
let result;
|
|
389
|
-
let bubblingResult = false;
|
|
390
|
-
try {
|
|
391
|
-
await this.ensureMiddleware(req.url);
|
|
392
|
-
result = await this.runMiddleware({
|
|
393
|
-
request: req,
|
|
394
|
-
response: res,
|
|
395
|
-
parsedUrl: parsedUrl,
|
|
396
|
-
parsed: parsed
|
|
397
|
-
});
|
|
398
|
-
if ('response' in result) {
|
|
399
|
-
if (isMiddlewareInvoke) {
|
|
400
|
-
bubblingResult = true;
|
|
401
|
-
throw Object.defineProperty(new _tracer.BubbledError(true, result), "__NEXT_ERROR_CODE", {
|
|
402
|
-
value: "E394",
|
|
403
|
-
enumerable: false,
|
|
404
|
-
configurable: true
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
for (const [key, value] of Object.entries((0, _utils1.toNodeOutgoingHttpHeaders)(result.response.headers))){
|
|
408
|
-
if (key !== 'content-encoding' && value !== undefined) {
|
|
409
|
-
res.setHeader(key, value);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
res.statusCode = result.response.status;
|
|
413
|
-
const { originalResponse } = res;
|
|
414
|
-
if (result.response.body) {
|
|
415
|
-
await (0, _pipereadable.pipeToNodeResponse)(result.response.body, originalResponse);
|
|
416
|
-
} else {
|
|
417
|
-
originalResponse.end();
|
|
418
|
-
}
|
|
419
|
-
return true;
|
|
420
|
-
}
|
|
421
|
-
} catch (err) {
|
|
422
|
-
if (bubblingResult) {
|
|
423
|
-
throw err;
|
|
424
|
-
}
|
|
425
|
-
if ((0, _iserror.default)(err) && err.code === 'ENOENT') {
|
|
426
|
-
await this.render404(req, res, parsed);
|
|
427
|
-
return true;
|
|
428
|
-
}
|
|
429
|
-
if (err instanceof _utils.DecodeError) {
|
|
430
|
-
res.statusCode = 400;
|
|
431
|
-
await this.renderError(err, req, res, parsed.pathname || '');
|
|
432
|
-
return true;
|
|
433
|
-
}
|
|
434
|
-
const error = (0, _iserror.getProperError)(err);
|
|
435
|
-
console.error(error);
|
|
436
|
-
res.statusCode = 500;
|
|
437
|
-
await this.renderError(error, req, res, parsed.pathname || '');
|
|
438
|
-
return true;
|
|
439
|
-
}
|
|
440
|
-
return result.finished;
|
|
441
|
-
};
|
|
442
|
-
(0, _globalbehaviors.installGlobalBehaviors)(this.nextConfig);
|
|
443
|
-
// Load prefetch hints from the build output. This must happen before
|
|
444
|
-
// any render to ensure segment inlining decisions are available.
|
|
445
|
-
this.renderOpts.prefetchHints = this.getPrefetchHints();
|
|
446
|
-
const isDev = options.dev ?? false;
|
|
447
|
-
this.isDev = isDev;
|
|
448
|
-
this.sriEnabled = Boolean((_options_conf_experimental = options.conf.experimental) == null ? void 0 : (_options_conf_experimental_sri = _options_conf_experimental.sri) == null ? void 0 : _options_conf_experimental_sri.algorithm);
|
|
449
|
-
/**
|
|
450
|
-
* This sets environment variable to be used at the time of SSR by head.tsx.
|
|
451
|
-
* Using this from process.env allows targeting SSR by calling
|
|
452
|
-
* `process.env.__NEXT_OPTIMIZE_CSS`.
|
|
453
|
-
*/ if (this.renderOpts.optimizeCss) {
|
|
454
|
-
process.env.__NEXT_OPTIMIZE_CSS = JSON.stringify(true);
|
|
455
|
-
}
|
|
456
|
-
if (this.renderOpts.nextScriptWorkers) {
|
|
457
|
-
process.env.__NEXT_SCRIPT_WORKERS = JSON.stringify(true);
|
|
458
|
-
}
|
|
459
|
-
if (!this.minimalMode) {
|
|
460
|
-
this.imageResponseCache = new _responsecache.default(this.minimalMode);
|
|
461
|
-
}
|
|
462
|
-
if (!options.dev && !this.minimalMode && this.nextConfig.experimental.preloadEntriesOnStart) {
|
|
463
|
-
this.unstable_preloadEntries();
|
|
464
|
-
}
|
|
465
|
-
if (!options.dev) {
|
|
466
|
-
const { dynamicRoutes = [] } = this.getRoutesManifest() ?? {};
|
|
467
|
-
this.dynamicRoutes = dynamicRoutes.map((r)=>{
|
|
468
|
-
// TODO: can we just re-use the regex from the manifest?
|
|
469
|
-
const regex = (0, _routeregex.getRouteRegex)(r.page);
|
|
470
|
-
const match = (0, _routematcher.getRouteMatcher)(regex);
|
|
471
|
-
return {
|
|
472
|
-
match,
|
|
473
|
-
page: r.page,
|
|
474
|
-
re: regex.re
|
|
475
|
-
};
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
// ensure options are set when loadConfig isn't called
|
|
479
|
-
(0, _setuphttpagentenv.setHttpClientAndAgentOptions)(this.nextConfig);
|
|
480
|
-
// Intercept fetch and other testmode apis.
|
|
481
|
-
if (this.serverOptions.experimentalTestProxy) {
|
|
482
|
-
process.env.NEXT_PRIVATE_TEST_PROXY = 'true';
|
|
483
|
-
const { interceptTestApis } = // eslint-disable-next-line @next/internal/typechecked-require -- experimental/testmode is not built ins next/dist/esm
|
|
484
|
-
require('next/dist/experimental/testmode/server');
|
|
485
|
-
interceptTestApis();
|
|
486
|
-
}
|
|
487
|
-
this.middlewareManifestPath = (0, _path.join)(/* turbopackIgnore: true */ this.serverDistDir, _constants.MIDDLEWARE_MANIFEST);
|
|
488
|
-
// This is just optimization to fire prepare as soon as possible. It will be
|
|
489
|
-
// properly awaited later. We add the catch here to ensure that it does not
|
|
490
|
-
// cause a unhandled promise rejection. The promise rejection will be
|
|
491
|
-
// handled later on via the `await` when the request handler is called.
|
|
492
|
-
if (!options.dev) {
|
|
493
|
-
this.prepare().catch((err)=>{
|
|
494
|
-
console.error('Failed to prepare server', err);
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
// when using compile mode static env isn't inlined so we
|
|
498
|
-
// need to populate in normal runtime env
|
|
499
|
-
if (this.renderOpts.isExperimentalCompile) {
|
|
500
|
-
// immutableAssetToken only works with Turbopack, and `isExperimentalCompile` isn't supported
|
|
501
|
-
// with that anyway, so we can assign immutableAssetToken to deploymentId here
|
|
502
|
-
(0, _staticenv.populateStaticEnv)(this.nextConfig, this.deploymentId || '');
|
|
503
|
-
}
|
|
504
|
-
const shouldRemoveUncaughtErrorAndRejectionListeners = Boolean((_options_conf_experimental1 = options.conf.experimental) == null ? void 0 : _options_conf_experimental1.removeUncaughtErrorAndRejectionListeners);
|
|
505
|
-
(0, _processerrorhandlers.installProcessErrorHandlers)(shouldRemoveUncaughtErrorAndRejectionListeners);
|
|
506
|
-
}
|
|
507
|
-
async unstable_preloadEntries() {
|
|
508
|
-
// Ensure prepare process will be finished before preloading entries.
|
|
509
|
-
await this.prepare();
|
|
510
|
-
const appPathsManifest = this.getAppPathsManifest();
|
|
511
|
-
const pagesManifest = this.getPagesManifest();
|
|
512
|
-
await this.loadCustomCacheHandlers();
|
|
513
|
-
for (const page of Object.keys(pagesManifest || {})){
|
|
514
|
-
try {
|
|
515
|
-
await (0, _loadcomponents.loadComponents)({
|
|
516
|
-
distDir: this.distDir,
|
|
517
|
-
page,
|
|
518
|
-
isAppPath: false,
|
|
519
|
-
isDev: this.isDev,
|
|
520
|
-
sriEnabled: this.sriEnabled,
|
|
521
|
-
needsManifestsForLegacyReasons: false
|
|
522
|
-
});
|
|
523
|
-
} catch (_err) {
|
|
524
|
-
// Intentionally ignored because this is a preload step.
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
for (const page of Object.keys(appPathsManifest || {})){
|
|
528
|
-
try {
|
|
529
|
-
const { ComponentMod } = await (0, _loadcomponents.loadComponents)({
|
|
530
|
-
distDir: this.distDir,
|
|
531
|
-
page,
|
|
532
|
-
isAppPath: true,
|
|
533
|
-
isDev: this.isDev,
|
|
534
|
-
sriEnabled: this.sriEnabled,
|
|
535
|
-
needsManifestsForLegacyReasons: false
|
|
536
|
-
});
|
|
537
|
-
// we need to ensure fetch is patched before we require the page,
|
|
538
|
-
// otherwise if the fetch is patched by user code, we will be patching it
|
|
539
|
-
// too late and there won't be any caching behaviors
|
|
540
|
-
ComponentMod.patchFetch();
|
|
541
|
-
} catch (_err) {
|
|
542
|
-
// Intentionally ignored because this is a preload step.
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
async handleUpgrade() {
|
|
547
|
-
// The web server does not support web sockets, it's only used for HMR in
|
|
548
|
-
// development.
|
|
549
|
-
}
|
|
550
|
-
async loadInstrumentationModule() {
|
|
551
|
-
if (!this.serverOptions.dev) {
|
|
552
|
-
try {
|
|
553
|
-
this.instrumentation = await (0, _instrumentationglobalsexternal.getInstrumentationModule)(this.dir, this.nextConfig.distDir);
|
|
554
|
-
} catch (err) {
|
|
555
|
-
if (err.code !== 'MODULE_NOT_FOUND') {
|
|
556
|
-
throw Object.defineProperty(new Error('An error occurred while loading the instrumentation hook', {
|
|
557
|
-
cause: err
|
|
558
|
-
}), "__NEXT_ERROR_CODE", {
|
|
559
|
-
value: "E92",
|
|
560
|
-
enumerable: false,
|
|
561
|
-
configurable: true
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
return this.instrumentation;
|
|
567
|
-
}
|
|
568
|
-
async prepareImpl() {
|
|
569
|
-
await super.prepareImpl();
|
|
570
|
-
await this.runInstrumentationHookIfAvailable();
|
|
571
|
-
}
|
|
572
|
-
async runInstrumentationHookIfAvailable() {
|
|
573
|
-
await (0, _instrumentationglobalsexternal.ensureInstrumentationRegistered)(this.dir, this.nextConfig.distDir);
|
|
574
|
-
}
|
|
575
|
-
loadEnvConfig({ dev, forceReload }) {
|
|
576
|
-
(0, _env.loadEnvConfig)(this.dir, dev, _log, forceReload, forceReload ? (envFilePath)=>{
|
|
577
|
-
_log.info(`Reload env: ${envFilePath}`);
|
|
578
|
-
} : undefined);
|
|
579
|
-
}
|
|
580
|
-
async loadCustomCacheHandlers() {
|
|
581
|
-
const { cacheMaxMemorySize, cacheHandlers } = this.nextConfig;
|
|
582
|
-
if (!cacheHandlers) return;
|
|
583
|
-
// If we've already initialized the cache handlers interface, don't do it
|
|
584
|
-
// again.
|
|
585
|
-
if (!(0, _handlers.initializeCacheHandlers)(cacheMaxMemorySize)) return;
|
|
586
|
-
for (const [kind, handler] of Object.entries(cacheHandlers)){
|
|
587
|
-
if (!handler) continue;
|
|
588
|
-
(0, _handlers.setCacheHandler)(kind, (0, _interopdefault.interopDefault)(await dynamicImportEsmDefault((0, _formatdynamicimportpath.formatDynamicImportPath)(this.distDir, handler))));
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
async getIncrementalCache({ requestHeaders }) {
|
|
592
|
-
const dev = !!this.dev;
|
|
593
|
-
let CacheHandler;
|
|
594
|
-
const { cacheHandler } = this.nextConfig;
|
|
595
|
-
if (cacheHandler) {
|
|
596
|
-
CacheHandler = (0, _interopdefault.interopDefault)(await dynamicImportEsmDefault((0, _formatdynamicimportpath.formatDynamicImportPath)(this.distDir, cacheHandler)));
|
|
597
|
-
}
|
|
598
|
-
await this.loadCustomCacheHandlers();
|
|
599
|
-
// incremental-cache is request specific
|
|
600
|
-
// although can have shared caches in module scope
|
|
601
|
-
// per-cache handler
|
|
602
|
-
return new _incrementalcache.IncrementalCache({
|
|
603
|
-
fs: this.getCacheFilesystem(),
|
|
604
|
-
dev,
|
|
605
|
-
requestHeaders,
|
|
606
|
-
allowedRevalidateHeaderKeys: this.nextConfig.experimental.allowedRevalidateHeaderKeys,
|
|
607
|
-
minimalMode: this.minimalMode,
|
|
608
|
-
serverDistDir: this.serverDistDir,
|
|
609
|
-
fetchCacheKeyPrefix: this.nextConfig.experimental.fetchCacheKeyPrefix,
|
|
610
|
-
maxMemoryCacheSize: this.nextConfig.cacheMaxMemorySize,
|
|
611
|
-
flushToDisk: !this.minimalMode && this.nextConfig.experimental.isrFlushToDisk,
|
|
612
|
-
getPrerenderManifest: ()=>this.getPrerenderManifest(),
|
|
613
|
-
CurCacheHandler: CacheHandler
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
getPublicDir() {
|
|
617
|
-
return (0, _path.join)(/* turbopackIgnore: true */ this.dir, _constants.CLIENT_PUBLIC_FILES_PATH);
|
|
618
|
-
}
|
|
619
|
-
getHasStaticDir() {
|
|
620
|
-
return _fs.default.existsSync(/* turbopackIgnore: true */ (0, _path.join)(/* turbopackIgnore: true */ this.dir, 'static'));
|
|
621
|
-
}
|
|
622
|
-
getPagesManifest() {
|
|
623
|
-
return (0, _loadmanifestexternal.loadManifest)((0, _path.join)(/* turbopackIgnore: true */ this.serverDistDir, _constants.PAGES_MANIFEST));
|
|
624
|
-
}
|
|
625
|
-
getAppPathsManifest() {
|
|
626
|
-
if (!this.enabledDirectories.app) return undefined;
|
|
627
|
-
return (0, _loadmanifestexternal.loadManifest)((0, _path.join)(/* turbopackIgnore: true */ this.serverDistDir, _constants.APP_PATHS_MANIFEST));
|
|
628
|
-
}
|
|
629
|
-
getinterceptionRoutePatterns() {
|
|
630
|
-
if (!this.enabledDirectories.app) return [];
|
|
631
|
-
const routesManifest = this.getRoutesManifest();
|
|
632
|
-
return (routesManifest == null ? void 0 : routesManifest.rewrites.beforeFiles.filter(_isinterceptionrouterewrite.isInterceptionRouteRewrite).map((rewrite)=>new RegExp(rewrite.regex))) ?? [];
|
|
633
|
-
}
|
|
634
|
-
async hasPage(pathname) {
|
|
635
|
-
var _this_nextConfig_i18n;
|
|
636
|
-
return !!(0, _require.getMaybePagePath)(pathname, this.distDir, (_this_nextConfig_i18n = this.nextConfig.i18n) == null ? void 0 : _this_nextConfig_i18n.locales, this.enabledDirectories.app);
|
|
637
|
-
}
|
|
638
|
-
getBuildId() {
|
|
639
|
-
const buildIdFile = (0, _path.join)(/* turbopackIgnore: true */ this.distDir, _constants.BUILD_ID_FILE);
|
|
640
|
-
try {
|
|
641
|
-
return _fs.default.readFileSync(/* turbopackIgnore: true */ buildIdFile, 'utf8').trim();
|
|
642
|
-
} catch (err) {
|
|
643
|
-
if (err.code === 'ENOENT') {
|
|
644
|
-
throw Object.defineProperty(new Error(`Could not find a production build in the '${this.distDir}' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id`), "__NEXT_ERROR_CODE", {
|
|
645
|
-
value: "E427",
|
|
646
|
-
enumerable: false,
|
|
647
|
-
configurable: true
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
throw err;
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
getEnabledDirectories(dev) {
|
|
654
|
-
const dir = dev ? this.dir : this.serverDistDir;
|
|
655
|
-
return {
|
|
656
|
-
app: (0, _findpagesdir.findDir)(dir, 'app') ? true : false,
|
|
657
|
-
pages: (0, _findpagesdir.findDir)(dir, 'pages') ? true : false
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
sendRenderResult(req, res, options) {
|
|
661
|
-
return (0, _sendpayload.sendRenderResult)({
|
|
662
|
-
req: req.originalRequest,
|
|
663
|
-
res: res.originalResponse,
|
|
664
|
-
result: options.result,
|
|
665
|
-
generateEtags: options.generateEtags,
|
|
666
|
-
poweredByHeader: options.poweredByHeader,
|
|
667
|
-
cacheControl: options.cacheControl
|
|
668
|
-
});
|
|
669
|
-
}
|
|
670
|
-
async runApi(req, res, query, match) {
|
|
671
|
-
const edgeFunctionsPages = this.getEdgeFunctionsPages();
|
|
672
|
-
for (const edgeFunctionsPage of edgeFunctionsPages){
|
|
673
|
-
if (edgeFunctionsPage === match.definition.pathname) {
|
|
674
|
-
const handledAsEdgeFunction = await this.runEdgeFunction({
|
|
675
|
-
req,
|
|
676
|
-
res,
|
|
677
|
-
query,
|
|
678
|
-
params: match.params,
|
|
679
|
-
page: match.definition.pathname,
|
|
680
|
-
appPaths: null
|
|
681
|
-
});
|
|
682
|
-
if (handledAsEdgeFunction) {
|
|
683
|
-
return true;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
// The module supports minimal mode, load the minimal module.
|
|
688
|
-
// Restore original URL as the handler handles it's own parsing
|
|
689
|
-
const parsedInitUrl = (0, _parseurl.parseUrl)((0, _requestmeta.getRequestMeta)(req, 'initURL') || req.url);
|
|
690
|
-
req.url = `${parsedInitUrl.pathname}${parsedInitUrl.search || ''}`;
|
|
691
|
-
const loader = new _nodemoduleloader.NodeModuleLoader();
|
|
692
|
-
const module = await loader.load(match.definition.filename);
|
|
693
|
-
(0, _requestmeta.addRequestMeta)(req.originalRequest, 'relativeProjectDir', (0, _path.relative)(process.cwd(), this.dir));
|
|
694
|
-
(0, _requestmeta.addRequestMeta)(req.originalRequest, 'distDir', this.distDir);
|
|
695
|
-
await module.handler(req.originalRequest, res.originalResponse, {
|
|
696
|
-
waitUntil: this.getWaitUntil()
|
|
697
|
-
});
|
|
698
|
-
return true;
|
|
699
|
-
}
|
|
700
|
-
async renderHTML(req, res, pathname, query, renderOpts) {
|
|
701
|
-
return (0, _tracer.getTracer)().trace(_constants1.NextNodeServerSpan.renderHTML, async ()=>this.renderHTMLImpl(req, res, pathname, query, renderOpts));
|
|
702
|
-
}
|
|
703
|
-
async renderHTMLImpl(req, res, pathname, query, renderOpts) {
|
|
704
|
-
if (process.env.NEXT_MINIMAL) {
|
|
705
|
-
throw Object.defineProperty(new Error('Invariant: renderHTML should not be called in minimal mode'), "__NEXT_ERROR_CODE", {
|
|
706
|
-
value: "E472",
|
|
707
|
-
enumerable: false,
|
|
708
|
-
configurable: true
|
|
709
|
-
});
|
|
710
|
-
// the `else` branch is needed for tree-shaking
|
|
711
|
-
} else {
|
|
712
|
-
// Due to the way we pass data by mutating `renderOpts`, we can't extend the
|
|
713
|
-
// object here but only updating its `nextFontManifest` field.
|
|
714
|
-
// https://github.com/vercel/next.js/blob/df7cbd904c3bd85f399d1ce90680c0ecf92d2752/packages/next/server/render.tsx#L947-L952
|
|
715
|
-
renderOpts.nextFontManifest = this.nextFontManifest;
|
|
716
|
-
if (this.enabledDirectories.app && renderOpts.isAppPath) {
|
|
717
|
-
return (0, _modulerender.lazyRenderAppPage)(req, res, pathname, query, // This code path does not service revalidations for unknown param
|
|
718
|
-
// shells. As a result, we don't need to pass in the unknown params.
|
|
719
|
-
null, renderOpts, this.getServerComponentsHmrCache(), {
|
|
720
|
-
buildId: this.buildId,
|
|
721
|
-
deploymentId: this.deploymentId,
|
|
722
|
-
clientAssetToken: this.nextConfig.experimental.immutableAssetToken ?? this.deploymentId
|
|
723
|
-
});
|
|
724
|
-
} else {
|
|
725
|
-
// TODO: re-enable this once we've refactored to use implicit matches
|
|
726
|
-
// throw new Error('Invariant: render should have used routeModule')
|
|
727
|
-
return (0, _modulerender1.lazyRenderPagesPage)(req.originalRequest, res.originalResponse, pathname, query, renderOpts, {
|
|
728
|
-
buildId: this.buildId,
|
|
729
|
-
deploymentId: this.deploymentId,
|
|
730
|
-
clientAssetToken: this.nextConfig.experimental.immutableAssetToken ?? this.deploymentId,
|
|
731
|
-
customServer: this.serverOptions.customServer || undefined
|
|
732
|
-
}, {
|
|
733
|
-
isFallback: false,
|
|
734
|
-
isDraftMode: renderOpts.isDraftMode,
|
|
735
|
-
developmentNotFoundSourcePage: (0, _requestmeta.getRequestMeta)(req, 'developmentNotFoundSourcePage')
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
async imageOptimizer(req, res, paramsResult, previousCacheEntry) {
|
|
741
|
-
if (process.env.NEXT_MINIMAL) {
|
|
742
|
-
throw Object.defineProperty(new Error('invariant: imageOptimizer should not be called in minimal mode'), "__NEXT_ERROR_CODE", {
|
|
743
|
-
value: "E506",
|
|
744
|
-
enumerable: false,
|
|
745
|
-
configurable: true
|
|
746
|
-
});
|
|
747
|
-
} else {
|
|
748
|
-
const { imageOptimizer, fetchExternalImage, fetchInternalImage } = require('./image-optimizer');
|
|
749
|
-
const handleInternalReq = async (newReq, newRes)=>{
|
|
750
|
-
if (newReq.url === req.url) {
|
|
751
|
-
throw Object.defineProperty(new Error(`Invariant attempted to optimize _next/image itself`), "__NEXT_ERROR_CODE", {
|
|
752
|
-
value: "E496",
|
|
753
|
-
enumerable: false,
|
|
754
|
-
configurable: true
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
|
-
if (!this.routerServerHandler) {
|
|
758
|
-
throw Object.defineProperty(new Error(`Invariant missing routerServerHandler`), "__NEXT_ERROR_CODE", {
|
|
759
|
-
value: "E317",
|
|
760
|
-
enumerable: false,
|
|
761
|
-
configurable: true
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
await this.routerServerHandler(newReq, newRes);
|
|
765
|
-
return;
|
|
766
|
-
};
|
|
767
|
-
let { href } = paramsResult;
|
|
768
|
-
if (process.env.__NEXT_TEST_MODE && process.env.IS_TURBOPACK_TEST && !paramsResult.isAbsolute) {
|
|
769
|
-
// Forward the dpl query param from the original /_next/image request to the
|
|
770
|
-
// internal static file request so that the static file validation in
|
|
771
|
-
// resolve-routes.ts can verify it.
|
|
772
|
-
const dpl = typeof req.url === 'string' ? new URL(req.url, 'http://n').searchParams.get('dpl') : undefined;
|
|
773
|
-
if (dpl) {
|
|
774
|
-
href += `${href.includes('?') ? '&' : '?'}dpl=${dpl}`;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
const imageUpstream = paramsResult.isAbsolute ? await fetchExternalImage(href, this.nextConfig.images.dangerouslyAllowLocalIP, this.nextConfig.images.maximumResponseBody, this.nextConfig.images.maximumRedirects) : await fetchInternalImage(href, req.originalRequest, res.originalResponse, this.nextConfig.images.maximumResponseBody, handleInternalReq);
|
|
778
|
-
return imageOptimizer(imageUpstream, paramsResult, this.nextConfig, {
|
|
779
|
-
isDev: this.dev,
|
|
780
|
-
previousCacheEntry
|
|
781
|
-
});
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
getPagePath(pathname, locales) {
|
|
785
|
-
return (0, _require.getPagePath)(pathname, this.distDir, locales, this.enabledDirectories.app);
|
|
786
|
-
}
|
|
787
|
-
async renderPageComponent(ctx, bubbleNoFallback) {
|
|
788
|
-
const edgeFunctionsPages = this.getEdgeFunctionsPages() || [];
|
|
789
|
-
if (edgeFunctionsPages.length) {
|
|
790
|
-
const appPaths = this.getOriginalAppPaths(ctx.pathname);
|
|
791
|
-
const isAppPath = Array.isArray(appPaths);
|
|
792
|
-
let page = ctx.pathname;
|
|
793
|
-
if (isAppPath) {
|
|
794
|
-
// When it's an array, we need to pass all parallel routes to the loader.
|
|
795
|
-
page = appPaths[0];
|
|
796
|
-
}
|
|
797
|
-
for (const edgeFunctionsPage of edgeFunctionsPages){
|
|
798
|
-
if (edgeFunctionsPage === page) {
|
|
799
|
-
await this.runEdgeFunction({
|
|
800
|
-
req: ctx.req,
|
|
801
|
-
res: ctx.res,
|
|
802
|
-
query: ctx.query,
|
|
803
|
-
params: ctx.renderOpts.params,
|
|
804
|
-
page,
|
|
805
|
-
appPaths
|
|
806
|
-
});
|
|
807
|
-
return null;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
return super.renderPageComponent(ctx, bubbleNoFallback);
|
|
812
|
-
}
|
|
813
|
-
async findPageComponents({ locale, page, query, params, isAppPath, url }) {
|
|
814
|
-
return (0, _tracer.getTracer)().trace(_constants1.NextNodeServerSpan.findPageComponents, {
|
|
815
|
-
spanName: 'resolve page components',
|
|
816
|
-
attributes: {
|
|
817
|
-
'next.route': isAppPath ? (0, _apppaths.normalizeAppPath)(page) : page
|
|
818
|
-
}
|
|
819
|
-
}, ()=>this.findPageComponentsImpl({
|
|
820
|
-
locale,
|
|
821
|
-
page,
|
|
822
|
-
query,
|
|
823
|
-
params,
|
|
824
|
-
isAppPath,
|
|
825
|
-
url
|
|
826
|
-
}));
|
|
827
|
-
}
|
|
828
|
-
async findPageComponentsImpl({ locale, page, query, params, isAppPath, url: _url }) {
|
|
829
|
-
const pagePaths = [
|
|
830
|
-
page
|
|
831
|
-
];
|
|
832
|
-
if (locale) {
|
|
833
|
-
pagePaths.unshift(...pagePaths.map((path)=>`/${locale}${path === '/' ? '' : path}`));
|
|
834
|
-
}
|
|
835
|
-
for (const pagePath of pagePaths){
|
|
836
|
-
try {
|
|
837
|
-
const components = await (0, _loadcomponents.loadComponents)({
|
|
838
|
-
distDir: this.distDir,
|
|
839
|
-
page: pagePath,
|
|
840
|
-
isAppPath,
|
|
841
|
-
isDev: this.isDev,
|
|
842
|
-
sriEnabled: this.sriEnabled,
|
|
843
|
-
needsManifestsForLegacyReasons: false
|
|
844
|
-
});
|
|
845
|
-
if (locale && typeof components.Component === 'string' && !pagePath.startsWith(`/${locale}/`) && pagePath !== `/${locale}`) {
|
|
846
|
-
continue;
|
|
847
|
-
}
|
|
848
|
-
return {
|
|
849
|
-
components,
|
|
850
|
-
query: {
|
|
851
|
-
...!this.renderOpts.isExperimentalCompile && components.getStaticProps ? {} : query,
|
|
852
|
-
// For appDir params is excluded.
|
|
853
|
-
...(isAppPath ? {} : params) || {}
|
|
854
|
-
}
|
|
855
|
-
};
|
|
856
|
-
} catch (err) {
|
|
857
|
-
// we should only not throw if we failed to find the page
|
|
858
|
-
// in the pages-manifest
|
|
859
|
-
if (!(err instanceof _utils.PageNotFoundError)) {
|
|
860
|
-
throw err;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
return null;
|
|
865
|
-
}
|
|
866
|
-
getNextFontManifest() {
|
|
867
|
-
return (0, _loadmanifestexternal.loadManifest)((0, _path.join)(/* turbopackIgnore: true */ this.distDir, 'server', _constants.NEXT_FONT_MANIFEST + '.json'));
|
|
868
|
-
}
|
|
869
|
-
// Used in development only, overloaded in next-dev-server
|
|
870
|
-
logErrorWithOriginalStack(_err, _type) {
|
|
871
|
-
throw Object.defineProperty(new Error('Invariant: logErrorWithOriginalStack can only be called on the development server'), "__NEXT_ERROR_CODE", {
|
|
872
|
-
value: "E6",
|
|
873
|
-
enumerable: false,
|
|
874
|
-
configurable: true
|
|
875
|
-
});
|
|
876
|
-
}
|
|
877
|
-
// Used in development only, overloaded in next-dev-server
|
|
878
|
-
async ensurePage(_opts) {
|
|
879
|
-
throw Object.defineProperty(new Error('Invariant: ensurePage can only be called on the development server'), "__NEXT_ERROR_CODE", {
|
|
880
|
-
value: "E291",
|
|
881
|
-
enumerable: false,
|
|
882
|
-
configurable: true
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* Resolves `API` request, in development builds on demand
|
|
887
|
-
* @param req http request
|
|
888
|
-
* @param res http response
|
|
889
|
-
* @param pathname path of request
|
|
890
|
-
*/ async handleApiRequest(req, res, query, match) {
|
|
891
|
-
return this.runApi(req, res, query, match);
|
|
892
|
-
}
|
|
893
|
-
getCacheFilesystem() {
|
|
894
|
-
return _nodefsmethods.nodeFs;
|
|
895
|
-
}
|
|
896
|
-
normalizeReq(req) {
|
|
897
|
-
return !(req instanceof _node.NodeNextRequest) ? new _node.NodeNextRequest(req) : req;
|
|
898
|
-
}
|
|
899
|
-
normalizeRes(res) {
|
|
900
|
-
return !(res instanceof _node.NodeNextResponse) ? new _node.NodeNextResponse(res) : res;
|
|
901
|
-
}
|
|
902
|
-
getRequestHandler() {
|
|
903
|
-
const handler = this.makeRequestHandler();
|
|
904
|
-
if (this.serverOptions.experimentalTestProxy) {
|
|
905
|
-
const { wrapRequestHandlerNode } = // eslint-disable-next-line @next/internal/typechecked-require -- experimental/testmode is not built ins next/dist/esm
|
|
906
|
-
require('next/dist/experimental/testmode/server');
|
|
907
|
-
return wrapRequestHandlerNode(handler);
|
|
908
|
-
}
|
|
909
|
-
return handler;
|
|
910
|
-
}
|
|
911
|
-
/**
|
|
912
|
-
* @internal - this method is internal to Next.js and should not be used directly by end-users
|
|
913
|
-
*/ getRequestHandlerWithMetadata(meta) {
|
|
914
|
-
const handler = this.makeRequestHandler();
|
|
915
|
-
return (req, res, parsedUrl)=>{
|
|
916
|
-
(0, _requestmeta.setRequestMeta)(req, meta);
|
|
917
|
-
return handler(req, res, parsedUrl);
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
makeRequestHandler() {
|
|
921
|
-
// This is just optimization to fire prepare as soon as possible. It will be
|
|
922
|
-
// properly awaited later. We add the catch here to ensure that it does not
|
|
923
|
-
// cause an unhandled promise rejection. The promise rejection will be
|
|
924
|
-
// handled later on via the `await` when the request handler is called.
|
|
925
|
-
this.prepare().catch((err)=>{
|
|
926
|
-
console.error('Failed to prepare server', err);
|
|
927
|
-
});
|
|
928
|
-
const handler = super.getRequestHandler();
|
|
929
|
-
return (req, res, parsedUrl)=>handler(this.normalizeReq(req), this.normalizeRes(res), parsedUrl);
|
|
930
|
-
}
|
|
931
|
-
async revalidate({ urlPath, headers, opts }) {
|
|
932
|
-
const mocked = (0, _mockrequest.createRequestResponseMocks)({
|
|
933
|
-
url: urlPath,
|
|
934
|
-
headers
|
|
935
|
-
});
|
|
936
|
-
const handler = this.getRequestHandler();
|
|
937
|
-
await handler(new _node.NodeNextRequest(mocked.req), new _node.NodeNextResponse(mocked.res));
|
|
938
|
-
await mocked.res.hasStreamed;
|
|
939
|
-
if (mocked.res.getHeader('x-nextjs-cache') !== 'REVALIDATED' && mocked.res.statusCode !== 200 && !(mocked.res.statusCode === 404 && opts.unstable_onlyGenerated)) {
|
|
940
|
-
throw Object.defineProperty(new Error(`Invalid response ${mocked.res.statusCode}`), "__NEXT_ERROR_CODE", {
|
|
941
|
-
value: "E175",
|
|
942
|
-
enumerable: false,
|
|
943
|
-
configurable: true
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
async render(req, res, pathname, query, parsedUrl, internal = false) {
|
|
948
|
-
return super.render(this.normalizeReq(req), this.normalizeRes(res), pathname, query, parsedUrl, internal);
|
|
949
|
-
}
|
|
950
|
-
async renderToHTML(req, res, pathname, query) {
|
|
951
|
-
return super.renderToHTML(this.normalizeReq(req), this.normalizeRes(res), pathname, query);
|
|
952
|
-
}
|
|
953
|
-
async renderErrorToResponseImpl(ctx, err) {
|
|
954
|
-
const { req, res, query } = ctx;
|
|
955
|
-
const is404 = res.statusCode === 404;
|
|
956
|
-
if (is404 && this.enabledDirectories.app) {
|
|
957
|
-
if (this.dev) {
|
|
958
|
-
await this.ensurePage({
|
|
959
|
-
page: _constants.UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,
|
|
960
|
-
clientOnly: false,
|
|
961
|
-
url: req.url
|
|
962
|
-
}).catch(()=>{});
|
|
963
|
-
}
|
|
964
|
-
if (this.getEdgeFunctionsPages().includes(_constants.UNDERSCORE_NOT_FOUND_ROUTE_ENTRY)) {
|
|
965
|
-
await this.runEdgeFunction({
|
|
966
|
-
req,
|
|
967
|
-
res,
|
|
968
|
-
query: query || {},
|
|
969
|
-
params: {},
|
|
970
|
-
page: _constants.UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,
|
|
971
|
-
appPaths: null
|
|
972
|
-
});
|
|
973
|
-
return null;
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
return super.renderErrorToResponseImpl(ctx, err);
|
|
977
|
-
}
|
|
978
|
-
async renderError(err, req, res, pathname, query, setHeaders) {
|
|
979
|
-
return super.renderError(err, this.normalizeReq(req), this.normalizeRes(res), pathname, query, setHeaders);
|
|
980
|
-
}
|
|
981
|
-
async renderErrorToHTML(err, req, res, pathname, query) {
|
|
982
|
-
return super.renderErrorToHTML(err, this.normalizeReq(req), this.normalizeRes(res), pathname, query);
|
|
983
|
-
}
|
|
984
|
-
async render404(req, res, parsedUrl, setHeaders) {
|
|
985
|
-
return super.render404(this.normalizeReq(req), this.normalizeRes(res), parsedUrl, setHeaders);
|
|
986
|
-
}
|
|
987
|
-
getMiddlewareManifest() {
|
|
988
|
-
if (this.minimalMode) {
|
|
989
|
-
return null;
|
|
990
|
-
} else {
|
|
991
|
-
const manifest = require(this.middlewareManifestPath);
|
|
992
|
-
return manifest;
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
/** Returns the middleware routing item if there is one. */ async getMiddleware() {
|
|
996
|
-
var _manifest_middleware;
|
|
997
|
-
const manifest = this.getMiddlewareManifest();
|
|
998
|
-
const middleware = manifest == null ? void 0 : (_manifest_middleware = manifest.middleware) == null ? void 0 : _manifest_middleware['/'];
|
|
999
|
-
if (!middleware) {
|
|
1000
|
-
const middlewareModule = await this.loadNodeMiddleware();
|
|
1001
|
-
if (middlewareModule) {
|
|
1002
|
-
var _middlewareModule_config;
|
|
1003
|
-
return {
|
|
1004
|
-
match: (0, _middlewareroutematcher.getMiddlewareRouteMatcher)(((_middlewareModule_config = middlewareModule.config) == null ? void 0 : _middlewareModule_config.matchers) || [
|
|
1005
|
-
{
|
|
1006
|
-
regexp: '.*',
|
|
1007
|
-
originalSource: '/:path*'
|
|
1008
|
-
}
|
|
1009
|
-
]),
|
|
1010
|
-
page: '/'
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
return;
|
|
1014
|
-
}
|
|
1015
|
-
return {
|
|
1016
|
-
match: getMiddlewareMatcher(middleware),
|
|
1017
|
-
page: '/'
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
getEdgeFunctionsPages() {
|
|
1021
|
-
const manifest = this.getMiddlewareManifest();
|
|
1022
|
-
if (!manifest) {
|
|
1023
|
-
return [];
|
|
1024
|
-
}
|
|
1025
|
-
return Object.keys(manifest.functions);
|
|
1026
|
-
}
|
|
1027
|
-
/**
|
|
1028
|
-
* Get information for the edge function located in the provided page
|
|
1029
|
-
* folder. If the edge function info can't be found it will throw
|
|
1030
|
-
* an error.
|
|
1031
|
-
*/ getEdgeFunctionInfo(params) {
|
|
1032
|
-
const manifest = this.getMiddlewareManifest();
|
|
1033
|
-
if (!manifest) {
|
|
1034
|
-
return null;
|
|
1035
|
-
}
|
|
1036
|
-
let foundPage;
|
|
1037
|
-
try {
|
|
1038
|
-
foundPage = (0, _denormalizepagepath.denormalizePagePath)((0, _normalizepagepath.normalizePagePath)(params.page));
|
|
1039
|
-
} catch (err) {
|
|
1040
|
-
return null;
|
|
1041
|
-
}
|
|
1042
|
-
let pageInfo = params.middleware ? manifest.middleware[foundPage] : manifest.functions[foundPage];
|
|
1043
|
-
if (!pageInfo) {
|
|
1044
|
-
if (!params.middleware) {
|
|
1045
|
-
throw new _utils.PageNotFoundError(foundPage);
|
|
1046
|
-
}
|
|
1047
|
-
return null;
|
|
1048
|
-
}
|
|
1049
|
-
return {
|
|
1050
|
-
name: pageInfo.name,
|
|
1051
|
-
paths: pageInfo.files.map((file)=>(0, _path.join)(/* turbopackIgnore: true */ this.distDir, file)),
|
|
1052
|
-
wasm: (pageInfo.wasm ?? []).map((binding)=>({
|
|
1053
|
-
...binding,
|
|
1054
|
-
filePath: (0, _path.join)(/* turbopackIgnore: true */ this.distDir, binding.filePath)
|
|
1055
|
-
})),
|
|
1056
|
-
assets: pageInfo.assets && pageInfo.assets.map((binding)=>{
|
|
1057
|
-
return {
|
|
1058
|
-
...binding,
|
|
1059
|
-
filePath: (0, _path.join)(/* turbopackIgnore: true */ this.distDir, binding.filePath)
|
|
1060
|
-
};
|
|
1061
|
-
}),
|
|
1062
|
-
env: pageInfo.env
|
|
1063
|
-
};
|
|
1064
|
-
}
|
|
1065
|
-
async loadNodeMiddleware() {
|
|
1066
|
-
if (!process.env.NEXT_MINIMAL) {
|
|
1067
|
-
try {
|
|
1068
|
-
var _functionsConfig_functions;
|
|
1069
|
-
const functionsConfig = this.dev ? {} : require((0, _path.join)(/* turbopackIgnore: true */ this.distDir, 'server', _constants.FUNCTIONS_CONFIG_MANIFEST));
|
|
1070
|
-
if (this.dev || (functionsConfig == null ? void 0 : (_functionsConfig_functions = functionsConfig.functions) == null ? void 0 : _functionsConfig_functions['/_middleware'])) {
|
|
1071
|
-
// if used with top level await, this will be a promise
|
|
1072
|
-
return require((0, _path.join)(/* turbopackIgnore: true */ this.distDir, 'server', 'middleware.js'));
|
|
1073
|
-
}
|
|
1074
|
-
} catch (err) {
|
|
1075
|
-
if ((0, _iserror.default)(err) && err.code !== 'ENOENT' && err.code !== 'MODULE_NOT_FOUND') {
|
|
1076
|
-
throw err;
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
* Checks if a middleware exists. This method is useful for the development
|
|
1083
|
-
* server where we need to check the filesystem. Here we just check the
|
|
1084
|
-
* middleware manifest.
|
|
1085
|
-
*/ async hasMiddleware(pathname) {
|
|
1086
|
-
const info = this.getEdgeFunctionInfo({
|
|
1087
|
-
page: pathname,
|
|
1088
|
-
middleware: true
|
|
1089
|
-
});
|
|
1090
|
-
const nodeMiddleware = await this.loadNodeMiddleware();
|
|
1091
|
-
if (!info && nodeMiddleware) {
|
|
1092
|
-
return true;
|
|
1093
|
-
}
|
|
1094
|
-
return Boolean(info && info.paths.length > 0);
|
|
1095
|
-
}
|
|
1096
|
-
/**
|
|
1097
|
-
* A placeholder for a function to be defined in the development server.
|
|
1098
|
-
* It will make sure that the root middleware or an edge function has been compiled
|
|
1099
|
-
* so that we can run it.
|
|
1100
|
-
*/ async ensureMiddleware(_url) {}
|
|
1101
|
-
async ensureEdgeFunction(_params) {}
|
|
1102
|
-
/**
|
|
1103
|
-
* This method gets all middleware matchers and execute them when the request
|
|
1104
|
-
* matches. It will make sure that each middleware exists and is compiled and
|
|
1105
|
-
* ready to be invoked. The development server will decorate it to add warns
|
|
1106
|
-
* and errors with rich traces.
|
|
1107
|
-
*/ async runMiddleware(params) {
|
|
1108
|
-
if (process.env.NEXT_MINIMAL) {
|
|
1109
|
-
throw Object.defineProperty(new Error('invariant: runMiddleware should not be called in minimal mode'), "__NEXT_ERROR_CODE", {
|
|
1110
|
-
value: "E276",
|
|
1111
|
-
enumerable: false,
|
|
1112
|
-
configurable: true
|
|
1113
|
-
});
|
|
1114
|
-
}
|
|
1115
|
-
// Middleware is skipped for on-demand revalidate requests
|
|
1116
|
-
if ((0, _apiutils.checkIsOnDemandRevalidate)(params.request, this.renderOpts.previewProps).isOnDemandRevalidate) {
|
|
1117
|
-
return {
|
|
1118
|
-
response: new Response(null, {
|
|
1119
|
-
headers: {
|
|
1120
|
-
'x-middleware-next': '1'
|
|
1121
|
-
}
|
|
1122
|
-
})
|
|
1123
|
-
};
|
|
1124
|
-
}
|
|
1125
|
-
let url;
|
|
1126
|
-
if (this.nextConfig.skipProxyUrlNormalize) {
|
|
1127
|
-
url = (0, _requestmeta.getRequestMeta)(params.request, 'initURL');
|
|
1128
|
-
} else {
|
|
1129
|
-
// For middleware to "fetch" we must always provide an absolute URL
|
|
1130
|
-
const query = (0, _querystring.urlQueryToSearchParams)(params.parsed.query).toString();
|
|
1131
|
-
const locale = (0, _requestmeta.getRequestMeta)(params.request, 'locale');
|
|
1132
|
-
url = `${(0, _requestmeta.getRequestMeta)(params.request, 'initProtocol')}://${this.fetchHostname || 'localhost'}:${this.port}${locale ? `/${locale}` : ''}${params.parsed.pathname}${query ? `?${query}` : ''}`;
|
|
1133
|
-
}
|
|
1134
|
-
if (!url.startsWith('http')) {
|
|
1135
|
-
throw Object.defineProperty(new Error('To use middleware you must provide a `hostname` and `port` to the Next.js Server'), "__NEXT_ERROR_CODE", {
|
|
1136
|
-
value: "E35",
|
|
1137
|
-
enumerable: false,
|
|
1138
|
-
configurable: true
|
|
1139
|
-
});
|
|
1140
|
-
}
|
|
1141
|
-
const page = {};
|
|
1142
|
-
const middleware = await this.getMiddleware();
|
|
1143
|
-
if (!middleware) {
|
|
1144
|
-
return {
|
|
1145
|
-
finished: false
|
|
1146
|
-
};
|
|
1147
|
-
}
|
|
1148
|
-
if (!await this.hasMiddleware(middleware.page)) {
|
|
1149
|
-
return {
|
|
1150
|
-
finished: false
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
await this.ensureMiddleware(params.request.url);
|
|
1154
|
-
const middlewareInfo = this.getEdgeFunctionInfo({
|
|
1155
|
-
page: middleware.page,
|
|
1156
|
-
middleware: true
|
|
1157
|
-
});
|
|
1158
|
-
const method = (params.request.method || 'GET').toUpperCase();
|
|
1159
|
-
const requestData = {
|
|
1160
|
-
headers: params.request.headers,
|
|
1161
|
-
method,
|
|
1162
|
-
nextConfig: {
|
|
1163
|
-
basePath: this.nextConfig.basePath,
|
|
1164
|
-
i18n: this.nextConfig.i18n,
|
|
1165
|
-
trailingSlash: this.nextConfig.trailingSlash,
|
|
1166
|
-
experimental: this.nextConfig.experimental
|
|
1167
|
-
},
|
|
1168
|
-
url: url,
|
|
1169
|
-
page,
|
|
1170
|
-
body: method !== 'GET' && method !== 'HEAD' ? (0, _requestmeta.getRequestMeta)(params.request, 'clonableBody') : undefined,
|
|
1171
|
-
signal: (0, _nextrequest.signalFromNodeResponse)(params.response.originalResponse),
|
|
1172
|
-
waitUntil: this.getWaitUntil()
|
|
1173
|
-
};
|
|
1174
|
-
let result;
|
|
1175
|
-
// if no middleware info check for Node.js middleware
|
|
1176
|
-
// this is not in the middleware-manifest as that historically
|
|
1177
|
-
// has only included edge-functions, we need to do a breaking
|
|
1178
|
-
// version bump for that manifest to write this info there if
|
|
1179
|
-
// we decide we want to
|
|
1180
|
-
if (!middlewareInfo) {
|
|
1181
|
-
let middlewareModule;
|
|
1182
|
-
middlewareModule = await this.loadNodeMiddleware();
|
|
1183
|
-
if (!middlewareModule) {
|
|
1184
|
-
throw new _utils.MiddlewareNotFoundError();
|
|
1185
|
-
}
|
|
1186
|
-
const adapterFn = middlewareModule.default || middlewareModule;
|
|
1187
|
-
const hasRequestBody = ![
|
|
1188
|
-
'HEAD',
|
|
1189
|
-
'GET'
|
|
1190
|
-
].includes(params.request.method) && Boolean(requestData.body);
|
|
1191
|
-
try {
|
|
1192
|
-
result = await adapterFn({
|
|
1193
|
-
handler: middlewareModule.proxy || middlewareModule.middleware || middlewareModule,
|
|
1194
|
-
request: {
|
|
1195
|
-
...requestData,
|
|
1196
|
-
body: hasRequestBody ? requestData.body.cloneBodyStream() : undefined
|
|
1197
|
-
},
|
|
1198
|
-
page: 'middleware'
|
|
1199
|
-
});
|
|
1200
|
-
} finally{
|
|
1201
|
-
if (hasRequestBody) {
|
|
1202
|
-
await requestData.body.finalize();
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
} else {
|
|
1206
|
-
const { run } = require('./web/sandbox');
|
|
1207
|
-
result = await run({
|
|
1208
|
-
distDir: this.distDir,
|
|
1209
|
-
name: middlewareInfo.name,
|
|
1210
|
-
paths: middlewareInfo.paths,
|
|
1211
|
-
edgeFunctionEntry: middlewareInfo,
|
|
1212
|
-
request: requestData,
|
|
1213
|
-
useCache: true,
|
|
1214
|
-
onWarning: params.onWarning,
|
|
1215
|
-
clientAssetToken: this.nextConfig.experimental.immutableAssetToken || this.deploymentId
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
if (!this.dev) {
|
|
1219
|
-
result.waitUntil.catch((error)=>{
|
|
1220
|
-
console.error(`Uncaught: middleware waitUntil errored`, error);
|
|
1221
|
-
});
|
|
1222
|
-
}
|
|
1223
|
-
if (!result) {
|
|
1224
|
-
this.render404(params.request, params.response, params.parsed);
|
|
1225
|
-
return {
|
|
1226
|
-
finished: true
|
|
1227
|
-
};
|
|
1228
|
-
}
|
|
1229
|
-
// Split compound (comma-separated) set-cookie headers
|
|
1230
|
-
if (result.response.headers.has('set-cookie')) {
|
|
1231
|
-
const cookies = result.response.headers.getSetCookie().flatMap((maybeCompoundCookie)=>(0, _utils1.splitCookiesString)(maybeCompoundCookie));
|
|
1232
|
-
// Clear existing header(s)
|
|
1233
|
-
result.response.headers.delete('set-cookie');
|
|
1234
|
-
// Append each cookie individually.
|
|
1235
|
-
for (const cookie of cookies){
|
|
1236
|
-
result.response.headers.append('set-cookie', cookie);
|
|
1237
|
-
}
|
|
1238
|
-
// Add cookies to request meta.
|
|
1239
|
-
(0, _requestmeta.addRequestMeta)(params.request, 'middlewareCookie', cookies);
|
|
1240
|
-
}
|
|
1241
|
-
return result;
|
|
1242
|
-
}
|
|
1243
|
-
getPrerenderManifest() {
|
|
1244
|
-
if (this._cachedPreviewManifest) {
|
|
1245
|
-
return this._cachedPreviewManifest;
|
|
1246
|
-
}
|
|
1247
|
-
this._cachedPreviewManifest = (0, _loadmanifestexternal.loadManifest)((0, _path.join)(/* turbopackIgnore: true */ this.distDir, _constants.PRERENDER_MANIFEST));
|
|
1248
|
-
return this._cachedPreviewManifest;
|
|
1249
|
-
}
|
|
1250
|
-
getPrefetchHints() {
|
|
1251
|
-
if (this._cachedPrefetchHints) {
|
|
1252
|
-
return this._cachedPrefetchHints;
|
|
1253
|
-
}
|
|
1254
|
-
this._cachedPrefetchHints = (0, _loadmanifestexternal.loadManifest)((0, _path.join)(/* turbopackIgnore: true */ this.distDir, _constants.SERVER_DIRECTORY, _constants.PREFETCH_HINTS), true, undefined, false, true // handleMissing: don't crash if the file doesn't exist
|
|
1255
|
-
) ?? {};
|
|
1256
|
-
return this._cachedPrefetchHints;
|
|
1257
|
-
}
|
|
1258
|
-
getRoutesManifest() {
|
|
1259
|
-
return (0, _tracer.getTracer)().trace(_constants1.NextNodeServerSpan.getRoutesManifest, ()=>(0, _loadmanifestexternal.loadManifest)((0, _path.join)(/* turbopackIgnore: true */ this.distDir, _constants.ROUTES_MANIFEST)));
|
|
1260
|
-
}
|
|
1261
|
-
attachRequestMeta(req, parsedUrl, isUpgradeReq) {
|
|
1262
|
-
var _req_headers_xforwardedproto;
|
|
1263
|
-
// Injected in base-server.ts
|
|
1264
|
-
const protocol = ((_req_headers_xforwardedproto = req.headers['x-forwarded-proto']) == null ? void 0 : _req_headers_xforwardedproto.includes('https')) ? 'https' : 'http';
|
|
1265
|
-
// When there are hostname and port we build an absolute URL
|
|
1266
|
-
const initUrl = this.fetchHostname && this.port ? `${protocol}://${this.fetchHostname}:${this.port}${req.url}` : this.nextConfig.experimental.trustHostHeader ? `https://${req.headers.host || 'localhost'}${req.url}` : req.url;
|
|
1267
|
-
(0, _requestmeta.addRequestMeta)(req, 'initURL', initUrl);
|
|
1268
|
-
(0, _requestmeta.addRequestMeta)(req, 'initQuery', {
|
|
1269
|
-
...parsedUrl.query
|
|
1270
|
-
});
|
|
1271
|
-
(0, _requestmeta.addRequestMeta)(req, 'initProtocol', protocol);
|
|
1272
|
-
if (!isUpgradeReq) {
|
|
1273
|
-
var _this_nextConfig_experimental;
|
|
1274
|
-
const bodySizeLimit = (_this_nextConfig_experimental = this.nextConfig.experimental) == null ? void 0 : _this_nextConfig_experimental.proxyClientMaxBodySize;
|
|
1275
|
-
(0, _requestmeta.addRequestMeta)(req, 'clonableBody', (0, _bodystreams.getCloneableBody)(req.originalRequest, bodySizeLimit));
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
async runEdgeFunction(params) {
|
|
1279
|
-
if (process.env.NEXT_MINIMAL) {
|
|
1280
|
-
throw Object.defineProperty(new Error('Middleware is not supported in minimal mode. Please remove the `NEXT_MINIMAL` environment variable.'), "__NEXT_ERROR_CODE", {
|
|
1281
|
-
value: "E58",
|
|
1282
|
-
enumerable: false,
|
|
1283
|
-
configurable: true
|
|
1284
|
-
});
|
|
1285
|
-
}
|
|
1286
|
-
let edgeInfo;
|
|
1287
|
-
const { query, page, match } = params;
|
|
1288
|
-
if (!match) await this.ensureEdgeFunction({
|
|
1289
|
-
page,
|
|
1290
|
-
appPaths: params.appPaths,
|
|
1291
|
-
url: params.req.url
|
|
1292
|
-
});
|
|
1293
|
-
edgeInfo = this.getEdgeFunctionInfo({
|
|
1294
|
-
page,
|
|
1295
|
-
middleware: false
|
|
1296
|
-
});
|
|
1297
|
-
if (!edgeInfo) {
|
|
1298
|
-
return null;
|
|
1299
|
-
}
|
|
1300
|
-
// For edge to "fetch" we must always provide an absolute URL
|
|
1301
|
-
const isNextDataRequest = (0, _requestmeta.getRequestMeta)(params.req, 'isNextDataReq');
|
|
1302
|
-
const initialUrl = new URL((0, _requestmeta.getRequestMeta)(params.req, 'initURL') || '/', 'http://n');
|
|
1303
|
-
const queryString = (0, _querystring.urlQueryToSearchParams)({
|
|
1304
|
-
...Object.fromEntries(initialUrl.searchParams),
|
|
1305
|
-
...query,
|
|
1306
|
-
...params.params
|
|
1307
|
-
}).toString();
|
|
1308
|
-
if (isNextDataRequest) {
|
|
1309
|
-
params.req.headers['x-nextjs-data'] = '1';
|
|
1310
|
-
}
|
|
1311
|
-
initialUrl.search = queryString;
|
|
1312
|
-
const url = initialUrl.toString();
|
|
1313
|
-
if (!url.startsWith('http')) {
|
|
1314
|
-
throw Object.defineProperty(new Error('To use middleware you must provide a `hostname` and `port` to the Next.js Server'), "__NEXT_ERROR_CODE", {
|
|
1315
|
-
value: "E35",
|
|
1316
|
-
enumerable: false,
|
|
1317
|
-
configurable: true
|
|
1318
|
-
});
|
|
1319
|
-
}
|
|
1320
|
-
const { run } = require('./web/sandbox');
|
|
1321
|
-
const result = await run({
|
|
1322
|
-
distDir: this.distDir,
|
|
1323
|
-
name: edgeInfo.name,
|
|
1324
|
-
paths: edgeInfo.paths,
|
|
1325
|
-
edgeFunctionEntry: edgeInfo,
|
|
1326
|
-
request: {
|
|
1327
|
-
headers: params.req.headers,
|
|
1328
|
-
method: params.req.method,
|
|
1329
|
-
nextConfig: {
|
|
1330
|
-
basePath: this.nextConfig.basePath,
|
|
1331
|
-
i18n: this.nextConfig.i18n,
|
|
1332
|
-
trailingSlash: this.nextConfig.trailingSlash
|
|
1333
|
-
},
|
|
1334
|
-
url,
|
|
1335
|
-
page: {
|
|
1336
|
-
name: params.page,
|
|
1337
|
-
...params.params && {
|
|
1338
|
-
params: params.params
|
|
1339
|
-
}
|
|
1340
|
-
},
|
|
1341
|
-
body: (0, _requestmeta.getRequestMeta)(params.req, 'clonableBody'),
|
|
1342
|
-
signal: (0, _nextrequest.signalFromNodeResponse)(params.res.originalResponse),
|
|
1343
|
-
waitUntil: this.getWaitUntil()
|
|
1344
|
-
},
|
|
1345
|
-
useCache: true,
|
|
1346
|
-
onError: params.onError,
|
|
1347
|
-
onWarning: params.onWarning,
|
|
1348
|
-
incrementalCache: globalThis.__incrementalCache || (0, _requestmeta.getRequestMeta)(params.req, 'incrementalCache'),
|
|
1349
|
-
serverComponentsHmrCache: (0, _requestmeta.getRequestMeta)(params.req, 'serverComponentsHmrCache'),
|
|
1350
|
-
clientAssetToken: this.nextConfig.experimental.immutableAssetToken || this.deploymentId
|
|
1351
|
-
});
|
|
1352
|
-
if (result.fetchMetrics) {
|
|
1353
|
-
params.req.fetchMetrics = result.fetchMetrics;
|
|
1354
|
-
}
|
|
1355
|
-
if (!params.res.statusCode || params.res.statusCode < 400) {
|
|
1356
|
-
params.res.statusCode = result.response.status;
|
|
1357
|
-
params.res.statusMessage = result.response.statusText;
|
|
1358
|
-
}
|
|
1359
|
-
// TODO: (wyattjoh) investigate improving this
|
|
1360
|
-
result.response.headers.forEach((value, key)=>{
|
|
1361
|
-
// The append handling is special cased for `set-cookie`.
|
|
1362
|
-
if (key.toLowerCase() === 'set-cookie') {
|
|
1363
|
-
// TODO: (wyattjoh) replace with native response iteration when we can upgrade undici
|
|
1364
|
-
for (const cookie of (0, _utils1.splitCookiesString)(value)){
|
|
1365
|
-
params.res.appendHeader(key, cookie);
|
|
1366
|
-
}
|
|
1367
|
-
} else {
|
|
1368
|
-
params.res.appendHeader(key, value);
|
|
1369
|
-
}
|
|
1370
|
-
});
|
|
1371
|
-
const { originalResponse } = params.res;
|
|
1372
|
-
if (result.response.body) {
|
|
1373
|
-
await (0, _pipereadable.pipeToNodeResponse)(result.response.body, originalResponse);
|
|
1374
|
-
} else {
|
|
1375
|
-
originalResponse.end();
|
|
1376
|
-
}
|
|
1377
|
-
return result;
|
|
1378
|
-
}
|
|
1379
|
-
get serverDistDir() {
|
|
1380
|
-
if (this._serverDistDir) {
|
|
1381
|
-
return this._serverDistDir;
|
|
1382
|
-
}
|
|
1383
|
-
const serverDistDir = (0, _path.join)(/* turbopackIgnore: true */ this.distDir, _constants.SERVER_DIRECTORY);
|
|
1384
|
-
this._serverDistDir = serverDistDir;
|
|
1385
|
-
return serverDistDir;
|
|
1386
|
-
}
|
|
1387
|
-
async getFallbackErrorComponents(_url) {
|
|
1388
|
-
// Not implemented for production use cases, this is implemented on the
|
|
1389
|
-
// development server.
|
|
1390
|
-
return null;
|
|
1391
|
-
}
|
|
1392
|
-
async instrumentationOnRequestError(...args) {
|
|
1393
|
-
await super.instrumentationOnRequestError(...args);
|
|
1394
|
-
// For Node.js runtime production logs, in dev it will be overridden by next-dev-server
|
|
1395
|
-
if (!this.dev) {
|
|
1396
|
-
const [err, , , silenceLog] = args;
|
|
1397
|
-
if (!silenceLog) {
|
|
1398
|
-
this.logError(err);
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
onServerClose(listener) {
|
|
1403
|
-
this.cleanupListeners.add(listener);
|
|
1404
|
-
}
|
|
1405
|
-
async close() {
|
|
1406
|
-
await this.cleanupListeners.runAll();
|
|
1407
|
-
}
|
|
1408
|
-
getInternalWaitUntil() {
|
|
1409
|
-
this.internalWaitUntil ??= this.createInternalWaitUntil();
|
|
1410
|
-
return this.internalWaitUntil;
|
|
1411
|
-
}
|
|
1412
|
-
createInternalWaitUntil() {
|
|
1413
|
-
if (this.minimalMode) {
|
|
1414
|
-
throw Object.defineProperty(new _invarianterror.InvariantError('createInternalWaitUntil should never be called in minimal mode'), "__NEXT_ERROR_CODE", {
|
|
1415
|
-
value: "E540",
|
|
1416
|
-
enumerable: false,
|
|
1417
|
-
configurable: true
|
|
1418
|
-
});
|
|
1419
|
-
}
|
|
1420
|
-
const awaiter = new _awaiter.AwaiterOnce({
|
|
1421
|
-
onError: console.error
|
|
1422
|
-
});
|
|
1423
|
-
// TODO(after): warn if the process exits before these are awaited
|
|
1424
|
-
this.onServerClose(()=>awaiter.awaiting());
|
|
1425
|
-
return awaiter.waitUntil;
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
//# sourceMappingURL=next-server.js.map
|