/
opt
/
canhelp
/
node_modules
/
next
/
dist
/
lib
/
/opt/canhelp/node_modules/next/dist/lib
mkdir
upload
Name
Size
Mode
Actions
eslint/
-
0755
rm
framework/
-
0755
rm
fs/
-
0755
rm
helpers/
-
0755
rm
memory/
-
0755
rm
metadata/
-
0755
rm
typescript/
-
0755
rm
batcher.d.ts
2132
0644
edit
dl
rm
batcher.js
2166
0644
edit
dl
rm
batcher.js.map
4215
0644
edit
dl
rm
build-custom-route.d.ts
505
0644
edit
dl
rm
build-custom-route.js
1183
0644
edit
dl
rm
build-custom-route.js.map
2408
0644
edit
dl
rm
client-and-server-references.d.ts
455
0644
edit
dl
rm
client-and-server-references.js
1293
0644
edit
dl
rm
client-and-server-references.js.map
1727
0644
edit
dl
rm
coalesced-function.d.ts
327
0644
edit
dl
rm
coalesced-function.js
1088
0644
edit
dl
rm
coalesced-function.js.map
2019
0644
edit
dl
rm
compile-error.d.ts
52
0644
edit
dl
rm
compile-error.js
292
0644
edit
dl
rm
compile-error.js.map
232
0644
edit
dl
rm
constants.d.ts
7838
0644
edit
dl
rm
constants.js
14710
0644
edit
dl
rm
constants.js.map
14073
0644
edit
dl
rm
create-client-router-filter.d.ts
341
0644
edit
dl
rm
create-client-router-filter.js
2487
0644
edit
dl
rm
create-client-router-filter.js.map
3958
0644
edit
dl
rm
default-transpiled-packages.json
10
0644
edit
dl
rm
detached-promise.d.ts
387
0644
edit
dl
rm
detached-promise.js
891
0644
edit
dl
rm
detached-promise.js.map
1298
0644
edit
dl
rm
detect-typo.d.ts
105
0644
edit
dl
rm
detect-typo.js
1521
0644
edit
dl
rm
detect-typo.js.map
2793
0644
edit
dl
rm
download-swc.d.ts
257
0644
edit
dl
rm
download-swc.js
7213
0644
edit
dl
rm
download-swc.js.map
8284
0644
edit
dl
rm
error-telemetry-utils.d.ts
650
0644
edit
dl
rm
error-telemetry-utils.js
1445
0644
edit
dl
rm
error-telemetry-utils.js.map
2403
0644
edit
dl
rm
fallback.d.ts
1585
0644
edit
dl
rm
fallback.js
3319
0644
edit
dl
rm
fallback.js.map
3896
0644
edit
dl
rm
fatal-error.d.ts
50
0644
edit
dl
rm
fatal-error.js
284
0644
edit
dl
rm
fatal-error.js.map
226
0644
edit
dl
rm
file-exists.d.ts
169
0644
edit
dl
rm
file-exists.js
1423
0644
edit
dl
rm
file-exists.js.map
1476
0644
edit
dl
rm
find-config.d.ts
314
0644
edit
dl
rm
find-config.js
3464
0644
edit
dl
rm
find-config.js.map
5028
0644
edit
dl
rm
find-pages-dir.d.ts
206
0644
edit
dl
rm
find-pages-dir.js
1560
0644
edit
dl
rm
find-pages-dir.js.map
1596
0644
edit
dl
rm
find-root.d.ts
133
0644
edit
dl
rm
find-root.js
4597
0644
edit
dl
rm
find-root.js.map
4352
0644
edit
dl
rm
format-cli-help-output.d.ts
174
0644
edit
dl
rm
format-cli-help-output.js
2849
0644
edit
dl
rm
format-cli-help-output.js.map
4919
0644
edit
dl
rm
format-dynamic-import-path.d.ts
419
0644
edit
dl
rm
format-dynamic-import-path.js
784
0644
edit
dl
rm
format-dynamic-import-path.js.map
1175
0644
edit
dl
rm
format-server-error.d.ts
368
0644
edit
dl
rm
format-server-error.js
2688
0644
edit
dl
rm
format-server-error.js.map
3784
0644
edit
dl
rm
generate-interception-routes-rewrites.d.ts
319
0644
edit
dl
rm
generate-interception-routes-rewrites.js
3287
0644
edit
dl
rm
generate-interception-routes-rewrites.js.map
4364
0644
edit
dl
rm
get-files-in-dir.d.ts
75
0644
edit
dl
rm
get-files-in-dir.js
927
0644
edit
dl
rm
get-files-in-dir.js.map
1186
0644
edit
dl
rm
get-network-host.d.ts
80
0644
edit
dl
rm
get-network-host.js
1423
0644
edit
dl
rm
get-network-host.js.map
1929
0644
edit
dl
rm
get-package-version.d.ts
364
0644
edit
dl
rm
get-package-version.js
3696
0644
edit
dl
rm
get-package-version.js.map
3230
0644
edit
dl
rm
get-project-dir.d.ts
85
0644
edit
dl
rm
get-project-dir.js
1904
0644
edit
dl
rm
get-project-dir.js.map
2378
0644
edit
dl
rm
has-necessary-dependencies.d.ts
1212
0644
edit
dl
rm
has-necessary-dependencies.js
1638
0644
edit
dl
rm
has-necessary-dependencies.js.map
3715
0644
edit
dl
rm
import-next-warning.d.ts
11
0644
edit
dl
rm
import-next-warning.js
1827
0644
edit
dl
rm
import-next-warning.js.map
534
0644
edit
dl
rm
inline-static-env.d.ts
203
0644
edit
dl
rm
inline-static-env.js
4619
0644
edit
dl
rm
inline-static-env.js.map
7098
0644
edit
dl
rm
install-dependencies.d.ts
170
0644
edit
dl
rm
install-dependencies.js
1356
0644
edit
dl
rm
install-dependencies.js.map
1938
0644
edit
dl
rm
interop-default.d.ts
55
0644
edit
dl
rm
interop-default.js
325
0644
edit
dl
rm
interop-default.js.map
310
0644
edit
dl
rm
is-api-route.d.ts
61
0644
edit
dl
rm
is-api-route.js
373
0644
edit
dl
rm
is-api-route.js.map
380
0644
edit
dl
rm
is-app-page-route.d.ts
64
0644
edit
dl
rm
is-app-page-route.js
334
0644
edit
dl
rm
is-app-page-route.js.map
333
0644
edit
dl
rm
is-app-route-route.d.ts
65
0644
edit
dl
rm
is-app-route-route.js
339
0644
edit
dl
rm
is-app-route-route.js.map
339
0644
edit
dl
rm
is-edge-runtime.d.ts
126
0644
edit
dl
rm
is-edge-runtime.js
445
0644
edit
dl
rm
is-edge-runtime.js.map
580
0644
edit
dl
rm
is-error.d.ts
440
0644
edit
dl
rm
is-error.js
2389
0644
edit
dl
rm
is-error.js.map
2863
0644
edit
dl
rm
is-internal-component.d.ts
144
0644
edit
dl
rm
is-internal-component.js
881
0644
edit
dl
rm
is-internal-component.js.map
747
0644
edit
dl
rm
is-serializable-props.d.ts
228
0644
edit
dl
rm
is-serializable-props.js
4694
0644
edit
dl
rm
is-serializable-props.js.map
6522
0644
edit
dl
rm
known-edge-safe-packages.json
18
0644
edit
dl
rm
load-custom-routes.d.ts
1510
0644
edit
dl
rm
load-custom-routes.js
22871
0644
edit
dl
rm
load-custom-routes.js.map
38658
0644
edit
dl
rm
mime-type.d.ts
230
0644
edit
dl
rm
mime-type.js
444
0644
edit
dl
rm
mime-type.js.map
458
0644
edit
dl
rm
mkcert.d.ts
229
0644
edit
dl
rm
mkcert.js
8283
0644
edit
dl
rm
mkcert.js.map
9760
0644
edit
dl
rm
multi-file-writer.d.ts
1465
0644
edit
dl
rm
multi-file-writer.js
2573
0644
edit
dl
rm
multi-file-writer.js.map
4200
0644
edit
dl
rm
needs-experimental-react.d.ts
136
0644
edit
dl
rm
needs-experimental-react.js
484
0644
edit
dl
rm
needs-experimental-react.js.map
697
0644
edit
dl
rm
non-nullable.d.ts
75
0644
edit
dl
rm
non-nullable.js
334
0644
edit
dl
rm
non-nullable.js.map
352
0644
edit
dl
rm
normalize-path.d.ts
61
0644
edit
dl
rm
normalize-path.js
549
0644
edit
dl
rm
normalize-path.js.map
437
0644
edit
dl
rm
oxford-comma-list.d.ts
69
0644
edit
dl
rm
oxford-comma-list.js
451
0644
edit
dl
rm
oxford-comma-list.js.map
718
0644
edit
dl
rm
page-types.d.ts
97
0644
edit
dl
rm
page-types.js
431
0644
edit
dl
rm
page-types.js.map
273
0644
edit
dl
rm
patch-incorrect-lockfile.d.ts
324
0644
edit
dl
rm
patch-incorrect-lockfile.js
7036
0644
edit
dl
rm
patch-incorrect-lockfile.js.map
9197
0644
edit
dl
rm
pick.d.ts
83
0644
edit
dl
rm
pick.js
368
0644
edit
dl
rm
pick.js.map
513
0644
edit
dl
rm
picocolors.d.ts
1453
0644
edit
dl
rm
picocolors.js
5375
0644
edit
dl
rm
picocolors.js.map
6288
0644
edit
dl
rm
pretty-bytes.d.ts
76
0644
edit
dl
rm
pretty-bytes.js
3056
0644
edit
dl
rm
pretty-bytes.js.map
4145
0644
edit
dl
rm
realpath.d.ts
87
0644
edit
dl
rm
realpath.js
572
0644
edit
dl
rm
realpath.js.map
795
0644
edit
dl
rm
recursive-copy.d.ts
218
0644
edit
dl
rm
recursive-copy.js
2860
0644
edit
dl
rm
recursive-copy.js.map
4470
0644
edit
dl
rm
recursive-delete.d.ts
321
0644
edit
dl
rm
recursive-delete.js
2642
0644
edit
dl
rm
recursive-delete.js.map
4220
0644
edit
dl
rm
recursive-readdir.d.ts
1054
0644
edit
dl
rm
recursive-readdir.js
5464
0644
edit
dl
rm
recursive-readdir.js.map
8486
0644
edit
dl
rm
redirect-status.d.ts
260
0644
edit
dl
rm
redirect-status.js
1285
0644
edit
dl
rm
redirect-status.js.map
1794
0644
edit
dl
rm
require-instrumentation-client.d.ts
0
0644
edit
dl
rm
require-instrumentation-client.js
1292
0644
edit
dl
rm
require-instrumentation-client.js.map
1947
0644
edit
dl
rm
resolve-from.d.ts
102
0644
edit
dl
rm
resolve-from.js
2144
0644
edit
dl
rm
resolve-from.js.map
2644
0644
edit
dl
rm
route-pattern-normalizer.d.ts
1101
0644
edit
dl
rm
route-pattern-normalizer.js
4502
0644
edit
dl
rm
route-pattern-normalizer.js.map
6605
0644
edit
dl
rm
scheduler.d.ts
1583
0644
edit
dl
rm
scheduler.js
1863
0644
edit
dl
rm
scheduler.js.map
3480
0644
edit
dl
rm
semver-noop.d.ts
46
0644
edit
dl
rm
semver-noop.js
471
0644
edit
dl
rm
semver-noop.js.map
452
0644
edit
dl
rm
server-external-packages.json
1281
0644
edit
dl
rm
setup-exception-listeners.d.ts
0
0644
edit
dl
rm
setup-exception-listeners.js
292
0644
edit
dl
rm
setup-exception-listeners.js.map
591
0644
edit
dl
rm
static-env.d.ts
605
0644
edit
dl
rm
static-env.js
2666
0644
edit
dl
rm
static-env.js.map
3853
0644
edit
dl
rm
try-to-parse-path.d.ts
696
0644
edit
dl
rm
try-to-parse-path.js
2542
0644
edit
dl
rm
try-to-parse-path.js.map
4461
0644
edit
dl
rm
turbopack-warning.d.ts
189
0644
edit
dl
rm
turbopack-warning.js
8777
0644
edit
dl
rm
turbopack-warning.js.map
11637
0644
edit
dl
rm
url.d.ts
333
0644
edit
dl
rm
url.js
1982
0644
edit
dl
rm
url.js.map
2942
0644
edit
dl
rm
verify-partytown-setup.d.ts
93
0644
edit
dl
rm
verify-partytown-setup.js
4918
0644
edit
dl
rm
verify-partytown-setup.js.map
5126
0644
edit
dl
rm
verify-root-layout.d.ts
335
0644
edit
dl
rm
verify-root-layout.js
5682
0644
edit
dl
rm
verify-root-layout.js.map
6625
0644
edit
dl
rm
verify-typescript-setup.d.ts
540
0644
edit
dl
rm
verify-typescript-setup.js
7481
0644
edit
dl
rm
verify-typescript-setup.js.map
8939
0644
edit
dl
rm
verifyAndLint.d.ts
247
0644
edit
dl
rm
verifyAndLint.js
3159
0644
edit
dl
rm
verifyAndLint.js.map
4663
0644
edit
dl
rm
wait.d.ts
180
0644
edit
dl
rm
wait.js
438
0644
edit
dl
rm
wait.js.map
494
0644
edit
dl
rm
with-promise-cache.d.ts
377
0644
edit
dl
rm
with-promise-cache.js
594
0644
edit
dl
rm
with-promise-cache.js.map
1396
0644
edit
dl
rm
worker.d.ts
1276
0644
edit
dl
rm
worker.js
8429
0644
edit
dl
rm
worker.js.map
13170
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/next/dist/lib/load-custom-routes.js
(22871B)
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 0 && (module.exports = { checkCustomRoutes: null, default: null, normalizeRouteRegex: null }); function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { enumerable: true, get: all[name] }); } _export(exports, { checkCustomRoutes: function() { return checkCustomRoutes; }, default: function() { return loadCustomRoutes; }, normalizeRouteRegex: function() { return normalizeRouteRegex; } }); const _picocolors = require("./picocolors"); const _escaperegexp = require("../shared/lib/escape-regexp"); const _trytoparsepath = require("./try-to-parse-path"); const _redirectstatus = require("./redirect-status"); const _url = require("./url"); const allowedHasTypes = new Set([ 'header', 'cookie', 'query', 'host' ]); const namedGroupsRegex = /\(\?<([a-zA-Z][a-zA-Z0-9]*)>/g; function normalizeRouteRegex(regex) { // clean up un-necessary escaping from regex.source which turns / into \\/ return regex.replace(/\\\//g, '/'); } function checkRedirect(route) { const invalidParts = []; let hadInvalidStatus = false; if (route.statusCode && !_redirectstatus.allowedStatusCodes.has(route['statusCode'])) { hadInvalidStatus = true; invalidParts.push(`\`statusCode\` is not undefined or valid statusCode`); } if (typeof route.permanent !== 'boolean' && !route['statusCode']) { invalidParts.push(`\`permanent\` is not set to \`true\` or \`false\``); } return { invalidParts, hadInvalidStatus }; } function checkHeader(route) { const invalidParts = []; if (!Array.isArray(route.headers)) { invalidParts.push('`headers` field must be an array'); } else if (route.headers.length === 0) { invalidParts.push('`headers` field cannot be empty'); } else { for (const header of route.headers){ if (!header || typeof header !== 'object') { invalidParts.push("`headers` items must be object with { key: '', value: '' }"); break; } if (typeof header.key !== 'string') { invalidParts.push('`key` in header item must be string'); break; } if (typeof header.value !== 'string') { invalidParts.push('`value` in header item must be string'); break; } } } return invalidParts; } function checkCustomRoutes(routes, type) { if (!Array.isArray(routes)) { console.error(`Error: ${type}s must return an array, received ${typeof routes}.\n` + `See here for more info: https://nextjs.org/docs/messages/routes-must-be-array`); process.exit(1); } let numInvalidRoutes = 0; let hadInvalidStatus = false; let hadInvalidHas = false; let hadInvalidMissing = false; const allowedKeys = new Set([ 'source', 'locale', 'has', 'missing' ]); if (type === 'rewrite') { allowedKeys.add('basePath'); allowedKeys.add('destination'); } if (type === 'redirect') { allowedKeys.add('basePath'); allowedKeys.add('statusCode'); allowedKeys.add('permanent'); allowedKeys.add('destination'); } if (type === 'header') { allowedKeys.add('basePath'); allowedKeys.add('headers'); } for (const route of routes){ if (!route || typeof route !== 'object') { console.error(`The route ${JSON.stringify(route)} is not a valid object with \`source\`${type !== 'middleware' ? ` and \`${type === 'header' ? 'headers' : 'destination'}\`` : ''}`); numInvalidRoutes++; continue; } if (type === 'rewrite' && route.basePath === false && !(route.destination.startsWith('http://') || route.destination.startsWith('https://'))) { console.error(`The route ${route.source} rewrites urls outside of the basePath. Please use a destination that starts with \`http://\` or \`https://\` https://nextjs.org/docs/messages/invalid-external-rewrite`); numInvalidRoutes++; continue; } const keys = Object.keys(route); const invalidKeys = keys.filter((key)=>!allowedKeys.has(key)); const invalidParts = []; if ('basePath' in route && typeof route.basePath !== 'undefined' && route.basePath !== false) { invalidParts.push('`basePath` must be undefined or false'); } if (typeof route.locale !== 'undefined' && route.locale !== false) { invalidParts.push('`locale` must be undefined or false'); } const checkInvalidHasMissing = (items, fieldName)=>{ let hadInvalidItem = false; if (typeof items !== 'undefined' && !Array.isArray(items)) { invalidParts.push(`\`${fieldName}\` must be undefined or valid has object`); hadInvalidItem = true; } else if (items) { const invalidHasItems = []; for (const hasItem of items){ let invalidHasParts = []; if (!allowedHasTypes.has(hasItem.type)) { invalidHasParts.push(`invalid type "${hasItem.type}"`); } if (typeof hasItem.key !== 'string' && hasItem.type !== 'host') { invalidHasParts.push(`invalid key "${hasItem.key}"`); } if (typeof hasItem.value !== 'undefined' && typeof hasItem.value !== 'string') { invalidHasParts.push(`invalid value "${hasItem.value}"`); } if (typeof hasItem.value === 'undefined' && hasItem.type === 'host') { invalidHasParts.push(`value is required for "host" type`); } if (invalidHasParts.length > 0) { invalidHasItems.push(`${invalidHasParts.join(', ')} for ${JSON.stringify(hasItem)}`); } } if (invalidHasItems.length > 0) { hadInvalidItem = true; const itemStr = `item${invalidHasItems.length === 1 ? '' : 's'}`; console.error(`Invalid \`${fieldName}\` ${itemStr}:\n` + invalidHasItems.join('\n')); console.error(); invalidParts.push(`invalid \`${fieldName}\` ${itemStr} found`); } } return hadInvalidItem; }; if (checkInvalidHasMissing(route.has, 'has')) { hadInvalidHas = true; } if (checkInvalidHasMissing(route.missing, 'missing')) { hadInvalidMissing = true; } if (!route.source) { invalidParts.push('`source` is missing'); } else if (typeof route.source !== 'string') { invalidParts.push('`source` is not a string'); } else if (!route.source.startsWith('/')) { invalidParts.push('`source` does not start with /'); } if (type === 'header') { invalidParts.push(...checkHeader(route)); } else if (type !== 'middleware') { let _route = route; if (!_route.destination) { invalidParts.push('`destination` is missing'); } else if (typeof _route.destination !== 'string') { invalidParts.push('`destination` is not a string'); } else if (type === 'rewrite' && !_route.destination.match(/^(\/|https:\/\/|http:\/\/)/)) { invalidParts.push('`destination` does not start with `/`, `http://`, or `https://`'); } } if (type === 'redirect') { const result = checkRedirect(route); hadInvalidStatus = hadInvalidStatus || result.hadInvalidStatus; invalidParts.push(...result.invalidParts); } let sourceTokens; if (typeof route.source === 'string' && route.source.startsWith('/')) { // only show parse error if we didn't already show error // for not being a string const { tokens, error, regexStr } = (0, _trytoparsepath.tryToParsePath)(route.source); if (error) { invalidParts.push('`source` parse failed'); } if (regexStr && regexStr.length > 4096) { invalidParts.push('`source` exceeds max built length of 4096'); } sourceTokens = tokens; } const hasSegments = new Set(); if (route.has) { for (const hasItem of route.has){ if (!hasItem.value && hasItem.key) { hasSegments.add(hasItem.key); } if (hasItem.value) { for (const match of hasItem.value.matchAll(namedGroupsRegex)){ if (match[1]) { hasSegments.add(match[1]); } } if (hasItem.type === 'host') { hasSegments.add('host'); } } } } // make sure no unnamed patterns are attempted to be used in the // destination as this can cause confusion and is not allowed if (typeof route.destination === 'string') { if (route.destination.startsWith('/') && Array.isArray(sourceTokens)) { const unnamedInDest = new Set(); for (const token of sourceTokens){ if (typeof token === 'object' && typeof token.name === 'number') { const unnamedIndex = new RegExp(`:${token.name}(?!\\d)`); if (route.destination.match(unnamedIndex)) { unnamedInDest.add(`:${token.name}`); } } } if (unnamedInDest.size > 0) { invalidParts.push(`\`destination\` has unnamed params ${[ ...unnamedInDest ].join(', ')}`); } else { const { tokens: destTokens, regexStr: destRegexStr, error: destinationParseFailed } = (0, _trytoparsepath.tryToParsePath)(route.destination, { handleUrl: true }); if (destRegexStr && destRegexStr.length > 4096) { invalidParts.push('`destination` exceeds max built length of 4096'); } if (destinationParseFailed) { invalidParts.push('`destination` parse failed'); } else { const sourceSegments = new Set(sourceTokens.map((item)=>typeof item === 'object' && item.name).filter(Boolean)); const invalidDestSegments = new Set(); for (const token of destTokens){ if (typeof token === 'object' && !sourceSegments.has(token.name) && !hasSegments.has(token.name)) { invalidDestSegments.add(token.name); } } if (invalidDestSegments.size) { invalidParts.push(`\`destination\` has segments not in \`source\` or \`has\` (${[ ...invalidDestSegments ].join(', ')})`); } } } } } const hasInvalidKeys = invalidKeys.length > 0; const hasInvalidParts = invalidParts.length > 0; if (hasInvalidKeys || hasInvalidParts) { console.error(`${invalidParts.join(', ')}${invalidKeys.length ? (hasInvalidParts ? ',' : '') + ` invalid field${invalidKeys.length === 1 ? '' : 's'}: ` + invalidKeys.join(',') : ''} for route ${JSON.stringify(route)}`); console.error(); numInvalidRoutes++; } } if (numInvalidRoutes > 0) { if (hadInvalidStatus) { console.error(`\nValid redirect statusCode values are ${[ ..._redirectstatus.allowedStatusCodes ].join(', ')}`); } if (hadInvalidHas) { console.error(`\nValid \`has\` object shape is ${JSON.stringify({ type: [ ...allowedHasTypes ].join(', '), key: 'the key to check for', value: 'undefined or a value string to match against' }, null, 2)}`); } if (hadInvalidMissing) { console.error(`\nValid \`missing\` object shape is ${JSON.stringify({ type: [ ...allowedHasTypes ].join(', '), key: 'the key to check for', value: 'undefined or a value string to match against' }, null, 2)}`); } console.error(); console.error(`Error: Invalid ${type}${numInvalidRoutes === 1 ? '' : 's'} found`); process.exit(1); } } function processRoutes(routes, config, type) { const _routes = routes; const newRoutes = []; const defaultLocales = []; if (config.i18n && type === 'redirect') { var _config_i18n; for (const item of ((_config_i18n = config.i18n) == null ? void 0 : _config_i18n.domains) || []){ defaultLocales.push({ locale: item.defaultLocale, base: `http${item.http ? '' : 's'}://${item.domain}` }); } defaultLocales.push({ locale: config.i18n.defaultLocale, base: '' }); } for (const r of _routes){ var _r_destination; const srcBasePath = config.basePath && r.basePath !== false ? config.basePath : ''; const isExternal = !((_r_destination = r.destination) == null ? void 0 : _r_destination.startsWith('/')); const destBasePath = srcBasePath && !isExternal ? srcBasePath : ''; if (config.i18n && r.locale !== false) { var _r_destination1; if (!isExternal) { defaultLocales.forEach((item)=>{ let destination; if (r.destination) { destination = item.base ? `${item.base}${destBasePath}${r.destination}` : `${destBasePath}${r.destination}`; } newRoutes.push({ ...r, destination, source: `${srcBasePath}/${item.locale}${r.source === '/' && !config.trailingSlash ? '' : r.source}` }); }); } r.source = `/:nextInternalLocale(${config.i18n.locales.map((locale)=>(0, _escaperegexp.escapeStringRegexp)(locale)).join('|')})${r.source === '/' && !config.trailingSlash ? '' : r.source}`; if (r.destination && ((_r_destination1 = r.destination) == null ? void 0 : _r_destination1.startsWith('/'))) { r.destination = `/:nextInternalLocale${r.destination === '/' && !config.trailingSlash ? '' : r.destination}`; } } r.source = `${srcBasePath}${r.source === '/' && srcBasePath ? '' : r.source}`; if (r.destination) { r.destination = `${destBasePath}${r.destination === '/' && destBasePath ? '' : r.destination}`; } newRoutes.push(r); } return newRoutes; } async function loadRedirects(config) { if (typeof config.redirects !== 'function') { return []; } let redirects = await config.redirects(); // check before we process the routes and after to ensure // they are still valid checkCustomRoutes(redirects, 'redirect'); // save original redirects before transforms if (Array.isArray(redirects)) { config._originalRedirects = redirects.map((r)=>({ ...r })); } redirects = processRoutes(redirects, config, 'redirect'); checkCustomRoutes(redirects, 'redirect'); return redirects; } async function loadRewrites(config) { // If assetPrefix is set, add a rewrite for `/${assetPrefix}/_next/*` // requests so that they are handled in any of dev, start, or deploy // automatically without the user having to configure this. // If the assetPrefix is an absolute URL, we still consider the path for automatic rewrite. // but hostname routing must be handled by the user let maybeAssetPrefixRewrite = []; if (config.assetPrefix) { let prefix = config.assetPrefix; if ((0, _url.isFullStringUrl)(config.assetPrefix) && URL.canParse(config.assetPrefix)) { prefix = new URL(config.assetPrefix).pathname; } if (prefix && prefix !== '/') { const assetPrefix = prefix.startsWith('/') ? prefix : `/${prefix}`; const basePath = config.basePath || ''; // If these are the same, then this would result in an infinite rewrite. if (assetPrefix !== basePath) { maybeAssetPrefixRewrite.push({ source: `${assetPrefix}/_next/:path+`, destination: `${basePath}/_next/:path+` }); } } } if (typeof config.rewrites !== 'function') { return { beforeFiles: [ ...maybeAssetPrefixRewrite ], afterFiles: [], fallback: [] }; } const _rewrites = await config.rewrites(); let beforeFiles = []; let afterFiles = []; let fallback = []; if (!Array.isArray(_rewrites) && typeof _rewrites === 'object' && Object.keys(_rewrites).every((key)=>key === 'beforeFiles' || key === 'afterFiles' || key === 'fallback')) { beforeFiles = _rewrites.beforeFiles || []; afterFiles = _rewrites.afterFiles || []; fallback = _rewrites.fallback || []; } else { afterFiles = _rewrites; } // check before we process the routes and after to ensure // they are still valid checkCustomRoutes(beforeFiles, 'rewrite'); checkCustomRoutes(afterFiles, 'rewrite'); checkCustomRoutes(fallback, 'rewrite'); // save original rewrites before transforms config._originalRewrites = { beforeFiles: beforeFiles.map((r)=>({ ...r })), afterFiles: afterFiles.map((r)=>({ ...r })), fallback: fallback.map((r)=>({ ...r })) }; beforeFiles = [ ...maybeAssetPrefixRewrite, ...processRoutes(beforeFiles, config, 'rewrite') ]; afterFiles = processRoutes(afterFiles, config, 'rewrite'); fallback = processRoutes(fallback, config, 'rewrite'); checkCustomRoutes(beforeFiles, 'rewrite'); checkCustomRoutes(afterFiles, 'rewrite'); checkCustomRoutes(fallback, 'rewrite'); return { beforeFiles, afterFiles, fallback }; } async function loadHeaders(config) { if (typeof config.headers !== 'function') { return []; } let headers = await config.headers(); // check before we process the routes and after to ensure // they are still valid checkCustomRoutes(headers, 'header'); headers = processRoutes(headers, config, 'header'); checkCustomRoutes(headers, 'header'); return headers; } async function loadCustomRoutes(config) { var _config_experimental; const [headers, rewrites, redirects] = await Promise.all([ loadHeaders(config), loadRewrites(config), loadRedirects(config) ]); const totalRewrites = rewrites.beforeFiles.length + rewrites.afterFiles.length + rewrites.fallback.length; const totalRoutes = headers.length + redirects.length + totalRewrites; if (totalRoutes > 1000) { console.warn((0, _picocolors.bold)((0, _picocolors.yellow)(`Warning: `)) + `total number of custom routes exceeds 1000, this can reduce performance. Route counts:\n` + `headers: ${headers.length}\n` + `rewrites: ${totalRewrites}\n` + `redirects: ${redirects.length}\n` + `See more info: https://nextjs.org/docs/messages/max-custom-routes-reached`); } if (((_config_experimental = config.experimental) == null ? void 0 : _config_experimental.useSkewCookie) && config.deploymentId) { headers.unshift({ source: '/:path*', headers: [ { key: 'Set-Cookie', value: `__vdpl=${config.deploymentId}; Path=/; HttpOnly` } ] }); } if (!config.skipTrailingSlashRedirect) { if (config.trailingSlash) { redirects.unshift({ source: '/:file((?!\\.well-known(?:/.*)?)(?:[^/]+/)*[^/]+\\.\\w+)/', destination: '/:file', permanent: true, locale: config.i18n ? false : undefined, internal: true, // don't run this redirect for _next/data requests missing: [ { type: 'header', key: 'x-nextjs-data' } ] }, { source: '/:notfile((?!\\.well-known(?:/.*)?)(?:[^/]+/)*[^/\\.]+)', destination: '/:notfile/', permanent: true, locale: config.i18n ? false : undefined, internal: true }); if (config.basePath) { redirects.unshift({ source: config.basePath, destination: config.basePath + '/', permanent: true, basePath: false, locale: config.i18n ? false : undefined, internal: true }); } } else { redirects.unshift({ source: '/:path+/', destination: '/:path+', permanent: true, locale: config.i18n ? false : undefined, internal: true }); if (config.basePath) { redirects.unshift({ source: config.basePath + '/', destination: config.basePath, permanent: true, basePath: false, locale: config.i18n ? false : undefined, internal: true }); } } } return { headers, rewrites, redirects }; } //# sourceMappingURL=load-custom-routes.js.map
Save
cmd:
run