@payloadcms/next 3.90.1 → 3.90.2

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.
@@ -239,10 +239,6 @@ var withPayload = (nextConfig = {}, options = {}) => {
239
239
  ...nextConfig.outputFileTracingExcludes || {},
240
240
  "**/*": [...nextConfig.outputFileTracingExcludes?.["**/*"] || [], "drizzle-kit", "drizzle-kit/api"]
241
241
  },
242
- outputFileTracingIncludes: {
243
- ...nextConfig.outputFileTracingIncludes || {},
244
- "**/*": [...nextConfig.outputFileTracingIncludes?.["**/*"] || [], "@libsql/client"]
245
- },
246
242
  turbopack: {
247
243
  ...nextConfig.turbopack || {}
248
244
  },
@@ -369,6 +365,9 @@ var withPayload = (nextConfig = {}, options = {}) => {
369
365
  process.env.NEXT_BASE_PATH = nextConfig.basePath;
370
366
  baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath;
371
367
  }
368
+ const trailingSlash = nextConfig.trailingSlash === true ? "true" : "false";
369
+ process.env.NEXT_TRAILING_SLASH = trailingSlash;
370
+ baseConfig.env.NEXT_TRAILING_SLASH = trailingSlash;
372
371
  if (!supportsTurbopackBuild) {
373
372
  return withPayloadLegacy(baseConfig);
374
373
  } else {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/withPayload/withPayload.js", "../../src/withPayload/withPayload.utils.js", "../../src/withPayload/withPayloadLegacy.js"],
4
- "sourcesContent": ["/**\n * These files must remain as plain JavaScript (.js) rather than TypeScript (.ts) because they are\n * imported directly in next.config.mjs files. Since next.config files run before the build process,\n * TypeScript compilation is not available. This ensures compatibility with all templates and\n * user projects regardless of their TypeScript setup.\n */\nimport {\n getNextjsVersion,\n supportsServerFastRefreshConfig,\n supportsTurbopackExternalizeTransitiveDependencies,\n} from './withPayload.utils.js'\nimport { withPayloadLegacy } from './withPayloadLegacy.js'\n\nconst poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n}\n\n/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const nextjsVersion = getNextjsVersion()\n\n const supportsTurbopackBuild = supportsTurbopackExternalizeTransitiveDependencies(nextjsVersion)\n const hasServerFastRefreshConfigOption = supportsServerFastRefreshConfig(nextjsVersion)\n\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload: detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n if (nextConfig.cacheComponents) {\n env.PAYLOAD_CACHE_COMPONENTS_ENABLED = 'true'\n }\n\n if (nextjsVersion?.major === 16 && !hasServerFastRefreshConfigOption) {\n console.warn(\n 'Payload: You are using an unsupported Next.js 16 version. You can find the supported Next.js versions here: https://payloadcms.com/docs/getting-started/installation',\n )\n }\n\n const consoleWarn = console.warn\n\n const sassWarningTexts = [\n // This warning is a lie - without silencing import deprecation warnings, sass will spam the console with deprecation warnings\n 'Future import deprecation is not yet active, so silencing it is unnecessary',\n // Sometimes happens despite silenceDeprecations\n 'The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0',\n ]\n console.warn = (...args) => {\n if (\n (typeof args[1] === 'string' && sassWarningTexts.some((text) => args[1].includes(text))) ||\n (typeof args[0] === 'string' && sassWarningTexts.some((text) => args[0].includes(text)))\n ) {\n return\n }\n\n consoleWarn(...args)\n }\n\n /** @type {import('next').NextConfig} */\n const baseConfig = {\n ...nextConfig,\n env,\n experimental: {\n ...(nextConfig.experimental || {}),\n // Server fast refresh breaks HMR\n ...(hasServerFastRefreshConfigOption ? { turbopackServerFastRefresh: false } : {}),\n },\n sassOptions: {\n ...(nextConfig.sassOptions || {}),\n /**\n * This prevents scss warning spam during pnpm dev that looks like this:\n * ⚠ ./test/admin/components/views/CustomMinimal/index.scss\n * Issue while running loader\n * SassWarning: Deprecation Warning on line 8, column 8 of file:///Users/alessio/Documents/GitHub/ payload/packages/ui/src/scss/styles.scss:8:8:\n * Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.\n *\n * More info and automated migrator: https://sass-lang.com/d/import\n *\n * 8 | @import 'queries';\n *\n *\n * packages/ui/src/scss/styles.scss 9:9 @import\n * test/admin/components/views/CustomMinimal/index.scss 1:9 root stylesheet\n *\n * @todo: update all outdated scss imports to use @use instead of @import. Then, we can remove this.\n */\n silenceDeprecations: [...(nextConfig.sassOptions?.silenceDeprecations || []), 'import'],\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev for two reasons:\n *\n * 1. Performance: Fewer files to compile means faster compilation speeds.\n * 2. Turbopack support: Webpack's externals are not supported by Turbopack.\n *\n * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to\n * externalized packages that are not resolvable from the project root. So including a package like\n * \"drizzle-kit\" in here would do nothing - Next.js will ignore the rule and still bundle the package -\n * because it detects that the package is not resolvable from the project root (= not directly installed\n * by the user in their own package.json).\n *\n * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly\n * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).\n *\n *\n *\n * We should only do this during development, not build, because externalizing these packages can hurt\n * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the\n * same package.\n *\n * Example:\n * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)\n * - payload (not in bundle, external) -> installs qs-esm (external because of importer)\n * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.\n *\n * During development, these bundle size difference do not matter much, and development speed /\n * turbopack support are more important.\n */\n [\n 'payload',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/drizzle',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/payload-cloud',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n // see: https://github.com/vercel/next.js/discussions/76991\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\n * See the explanation in the serverExternalPackages section above.\n * We need to force Webpack to emit require() calls for these packages, even though they are not\n * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.\n *\n * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the\n * entry point packages, as explained in the serverExternalPackages section above.\n */\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n ],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n }\n },\n }\n\n if (nextConfig.basePath) {\n process.env.NEXT_BASE_PATH = nextConfig.basePath\n baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n if (!supportsTurbopackBuild) {\n return withPayloadLegacy(baseConfig)\n } else {\n return {\n ...baseConfig,\n serverExternalPackages: [\n ...(baseConfig.serverExternalPackages || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n // Prevents turbopack build errors by the thread-stream package which is installed by pino\n 'pino',\n ],\n }\n }\n}\n\nexport default withPayload\n", " \n/**\n * This was taken and modified from https://github.com/getsentry/sentry-javascript/blob/15256034ee8150a5b7dcb97d23eca1a5486f0cae/packages/nextjs/src/config/util.ts\n *\n * MIT License\n *\n * Copyright (c) 2012 Functional Software, Inc. dba Sentry\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n * of the Software, and to permit persons to whom the Software is furnished to do\n * so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { readFileSync } from 'fs'\nimport { fileURLToPath } from 'url'\n\n/**\n * @param {string | undefined} input\n * @returns {number}\n */\nfunction _parseInt(input) {\n return parseInt(input || '', 10)\n}\n\n/**\n * Represents Semantic Versioning object\n * @typedef {Object} SemVer\n * @property {string} [buildmetadata]\n * @property {number} [canaryVersion] - undefined if not a canary version\n * @property {number} [major]\n * @property {number} [minor]\n * @property {number} [patch]\n * @property {string} [prerelease]\n */\n\n// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string\nconst SEMVER_REGEXP =\n /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*))*))?(?:\\+([0-9a-z-]+(?:\\.[0-9a-z-]+)*))?$/i\n\n/**\n * Parses input into a SemVer interface\n * @param {string} input - string representation of a semver version\n * @returns {SemVer}\n */\nexport function parseSemver(input) {\n const match = input.match(SEMVER_REGEXP) || []\n const major = _parseInt(match[1])\n const minor = _parseInt(match[2])\n const patch = _parseInt(match[3])\n\n const prerelease = match[4]\n const canaryVersion = prerelease?.startsWith('canary.')\n ? parseInt(prerelease.split('.')[1] || '0', 10)\n : undefined\n\n return {\n buildmetadata: match[5],\n canaryVersion,\n major: isNaN(major) ? undefined : major,\n minor: isNaN(minor) ? undefined : minor,\n patch: isNaN(patch) ? undefined : patch,\n prerelease: match[4],\n }\n}\n\n/**\n * Returns the version of Next.js installed in the project, or undefined if it cannot be determined.\n * @returns {SemVer | undefined}\n */\nexport function getNextjsVersion() {\n try {\n /** @type {string} */\n let pkgPath\n\n // Check if we're in ESM or CJS environment\n if (typeof import.meta?.resolve === 'function') {\n // ESM environment - use import.meta.resolve\n const pkgUrl = import.meta.resolve('next/package.json')\n // Use fileURLToPath for proper cross-platform path handling (Windows, macOS, Linux)\n // new URL().pathname returns '/C:/path' on Windows which causes path resolution issues\n pkgPath = fileURLToPath(pkgUrl)\n } else {\n // CJS environment - use require.resolve\n pkgPath = require.resolve('next/package.json')\n }\n\n const pkgJson = JSON.parse(readFileSync(pkgPath, 'utf8'))\n return parseSemver(pkgJson.version)\n } catch (e) {\n console.error('Payload: Error getting Next.js version', e)\n return undefined\n }\n}\n\n/**\n * Checks if the current Next.js version supports the `experimental.serverFastRefresh` option.\n * This was introduced in Next.js v16.2.2\n * @param {SemVer | undefined} version\n * @returns {boolean}\n */\nexport function supportsServerFastRefreshConfig(version) {\n if (!version) {\n return false\n }\n\n const { major, minor, patch } = version\n\n if (major === undefined || minor === undefined || patch === undefined) {\n return false\n }\n\n if (major > 16) {\n return true\n }\n\n if (major === 16) {\n if (minor > 2) {\n return true\n }\n if (minor === 2) {\n return patch >= 2\n }\n }\n\n return false\n}\n\n/**\n * Checks if the current Next.js version supports Turbopack externalize transitive dependencies.\n * This was introduced in Next.js v16.1.0-canary.3\n * @param {SemVer | undefined} version\n * @returns {boolean}\n */\nexport function supportsTurbopackExternalizeTransitiveDependencies(version) {\n if (!version) {\n return false\n }\n\n const { canaryVersion, major, minor, patch } = version\n\n if (major === undefined || minor === undefined) {\n return false\n }\n\n if (major > 16) {\n return true\n }\n\n if (major === 16) {\n if (minor > 1) {\n return true\n }\n if (minor === 1) {\n // 16.1.1+ and canaries support this feature\n if (patch > 0) {\n return true\n }\n if (canaryVersion !== undefined) {\n // 16.1.0-canary.3+\n return canaryVersion >= 3\n } else {\n // Next.js 16.1.0\n return true\n }\n }\n }\n\n return false\n}\n", "/**\n * Applies config options required to support Next.js versions before 16.1.0 and 16.1.0-canary.3.\n * @param {import('next').NextConfig} nextConfig\n * @returns {import('next').NextConfig}\n */\nexport const withPayloadLegacy = (nextConfig = {}) => {\n if (process.env.PAYLOAD_PATCH_TURBOPACK_WARNINGS !== 'false') {\n // TODO: This warning is thrown because we cannot externalize the entry-point package for client-s3, so we patch the warning to not show it.\n // We can remove this once Next.js implements https://github.com/vercel/next.js/discussions/76991\n const turbopackWarningText =\n 'Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.\\nTry to install it into the project directory by running'\n\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const turbopackConfigWarningText = \"Unrecognized key(s) in object: 'turbopack'\"\n\n const consoleWarn = console.warn\n console.warn = (...args) => {\n // Force to disable serverExternalPackages warnings: https://github.com/vercel/next.js/issues/68805\n if (\n (typeof args[1] === 'string' && args[1].includes(turbopackWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackWarningText))\n ) {\n return\n }\n\n // Add Payload-specific message after turbopack config warning in Next.js 15.2.x or lower.\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const hasTurbopackConfigWarning =\n (typeof args[1] === 'string' && args[1].includes(turbopackConfigWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackConfigWarningText))\n\n if (hasTurbopackConfigWarning) {\n consoleWarn(...args)\n consoleWarn(\n 'Payload: You can safely ignore the \"Invalid next.config\" warning above. This only occurs on Next.js 15.2.x or lower. We recommend upgrading to the latest supported Next.js version to resolve this warning.',\n )\n return\n }\n\n consoleWarn(...args)\n }\n }\n\n const isBuild = process.env.NODE_ENV === 'production'\n const isTurbopackNextjs15 = process.env.TURBOPACK === '1'\n const isTurbopackNextjs16 = process.env.TURBOPACK === 'auto'\n\n if (isBuild && (isTurbopackNextjs15 || isTurbopackNextjs16)) {\n throw new Error(\n 'Payload: Your Next.js version does not support using Turbopack for production builds. The *minimum* Next.js version required for Turbopack Builds is 16.1.0. Please upgrade to the latest supported Next.js version to resolve this error.',\n )\n }\n\n /** @type {import('next').NextConfig} */\n const toReturn = {\n ...nextConfig,\n serverExternalPackages: [\n // serverExternalPackages = webpack.externals, but with turbopack support and an additional check\n // for whether the package is resolvable from the project root\n ...(nextConfig.serverExternalPackages || []),\n // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.\n '@sentry/nextjs',\n ],\n }\n\n return toReturn\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;AC2BA,gBAA6B;AAC7B,iBAA8B;AA3B9B;AAiCA,SAASA,UAAUC,OAAK;AACtB,SAAOC,SAASD,SAAS,IAAI,EAAA;AAC/B;AAcA,IAAME,gBACJ;AAOK,SAASC,YAAYH,OAAK;AAC/B,QAAMI,QAAQJ,MAAMI,MAAMF,aAAA,KAAkB,CAAA;AAC5C,QAAMG,QAAQN,UAAUK,MAAM,CAAA,CAAE;AAChC,QAAME,QAAQP,UAAUK,MAAM,CAAA,CAAE;AAChC,QAAMG,QAAQR,UAAUK,MAAM,CAAA,CAAE;AAEhC,QAAMI,aAAaJ,MAAM,CAAA;AACzB,QAAMK,gBAAgBD,YAAYE,WAAW,SAAA,IACzCT,SAASO,WAAWG,MAAM,GAAA,EAAK,CAAA,KAAM,KAAK,EAAA,IAC1CC;AAEJ,SAAO;IACLC,eAAeT,MAAM,CAAA;IACrBK;IACAJ,OAAOS,MAAMT,KAAA,IAASO,SAAYP;IAClCC,OAAOQ,MAAMR,KAAA,IAASM,SAAYN;IAClCC,OAAOO,MAAMP,KAAA,IAASK,SAAYL;IAClCC,YAAYJ,MAAM,CAAA;EACpB;AACF;AAMO,SAASW,mBAAA;AACd,MAAI;AAEF,QAAIC;AAGJ,QAAI,OAAOC,aAAaC,YAAY,YAAY;AAE9C,YAAMC,SAASF,YAAYC,QAAQ,mBAAA;AAGnCF,oBAAUI,0BAAcD,MAAA;IAC1B,OAAO;AAELH,gBAAUK,gBAAgB,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,UAAA;EAC3B,OAAO;AACL,WAAO;MACL,GAAGA;MACHU,wBAAwB;QAAA,GAClBV,WAAWU,0BAA0B,CAAA;QACzC;QACA;QACA;QACA;QACA;QACA;;QAEA;MAAA;IAEJ;EACF;AACF;AAEA,IAAA,sBAAenC;",
6
- "names": ["_parseInt", "input", "parseInt", "SEMVER_REGEXP", "parseSemver", "match", "major", "minor", "patch", "prerelease", "canaryVersion", "startsWith", "split", "undefined", "buildmetadata", "isNaN", "getNextjsVersion", "pkgPath", "import", "resolve", "pkgUrl", "fileURLToPath", "require", "pkgJson", "JSON", "parse", "readFileSync", "version", "e", "console", "error", "supportsServerFastRefreshConfig", "supportsTurbopackExternalizeTransitiveDependencies", "withPayloadLegacy", "nextConfig", "process", "env", "PAYLOAD_PATCH_TURBOPACK_WARNINGS", "turbopackWarningText", "turbopackConfigWarningText", "consoleWarn", "console", "warn", "args", "includes", "hasTurbopackConfigWarning", "isBuild", "NODE_ENV", "isTurbopackNextjs15", "TURBOPACK", "isTurbopackNextjs16", "Error", "toReturn", "serverExternalPackages", "poweredByHeader", "key", "value", "withPayload", "nextConfig", "options", "nextjsVersion", "getNextjsVersion", "supportsTurbopackBuild", "supportsTurbopackExternalizeTransitiveDependencies", "hasServerFastRefreshConfigOption", "supportsServerFastRefreshConfig", "env", "experimental", "staleTimes", "dynamic", "console", "warn", "NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH", "cacheComponents", "PAYLOAD_CACHE_COMPONENTS_ENABLED", "major", "consoleWarn", "sassWarningTexts", "args", "some", "text", "includes", "baseConfig", "turbopackServerFastRefresh", "sassOptions", "silenceDeprecations", "outputFileTracingExcludes", "outputFileTracingIncludes", "turbopack", "headers", "headersFromConfig", "source", "serverExternalPackages", "process", "NODE_ENV", "devBundleServerPackages", "webpack", "webpackConfig", "webpackOptions", "incomingWebpackConfig", "externals", "plugins", "IgnorePlugin", "resourceRegExp", "resolve", "alias", "fallback", "aws4", "basePath", "NEXT_BASE_PATH", "withPayloadLegacy"]
4
+ "sourcesContent": ["/**\n * These files must remain as plain JavaScript (.js) rather than TypeScript (.ts) because they are\n * imported directly in next.config.mjs files. Since next.config files run before the build process,\n * TypeScript compilation is not available. This ensures compatibility with all templates and\n * user projects regardless of their TypeScript setup.\n */\nimport {\n getNextjsVersion,\n supportsServerFastRefreshConfig,\n supportsTurbopackExternalizeTransitiveDependencies,\n} from './withPayload.utils.js'\nimport { withPayloadLegacy } from './withPayloadLegacy.js'\n\nconst poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n}\n\n/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const nextjsVersion = getNextjsVersion()\n\n const supportsTurbopackBuild = supportsTurbopackExternalizeTransitiveDependencies(nextjsVersion)\n const hasServerFastRefreshConfigOption = supportsServerFastRefreshConfig(nextjsVersion)\n\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload: detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n if (nextConfig.cacheComponents) {\n env.PAYLOAD_CACHE_COMPONENTS_ENABLED = 'true'\n }\n\n if (nextjsVersion?.major === 16 && !hasServerFastRefreshConfigOption) {\n console.warn(\n 'Payload: You are using an unsupported Next.js 16 version. You can find the supported Next.js versions here: https://payloadcms.com/docs/getting-started/installation',\n )\n }\n\n const consoleWarn = console.warn\n\n const sassWarningTexts = [\n // This warning is a lie - without silencing import deprecation warnings, sass will spam the console with deprecation warnings\n 'Future import deprecation is not yet active, so silencing it is unnecessary',\n // Sometimes happens despite silenceDeprecations\n 'The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0',\n ]\n console.warn = (...args) => {\n if (\n (typeof args[1] === 'string' && sassWarningTexts.some((text) => args[1].includes(text))) ||\n (typeof args[0] === 'string' && sassWarningTexts.some((text) => args[0].includes(text)))\n ) {\n return\n }\n\n consoleWarn(...args)\n }\n\n /** @type {import('next').NextConfig} */\n const baseConfig = {\n ...nextConfig,\n env,\n experimental: {\n ...(nextConfig.experimental || {}),\n // Server fast refresh breaks HMR\n ...(hasServerFastRefreshConfigOption ? { turbopackServerFastRefresh: false } : {}),\n },\n sassOptions: {\n ...(nextConfig.sassOptions || {}),\n /**\n * This prevents scss warning spam during pnpm dev that looks like this:\n * ⚠ ./test/admin/components/views/CustomMinimal/index.scss\n * Issue while running loader\n * SassWarning: Deprecation Warning on line 8, column 8 of file:///Users/alessio/Documents/GitHub/ payload/packages/ui/src/scss/styles.scss:8:8:\n * Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.\n *\n * More info and automated migrator: https://sass-lang.com/d/import\n *\n * 8 | @import 'queries';\n *\n *\n * packages/ui/src/scss/styles.scss 9:9 @import\n * test/admin/components/views/CustomMinimal/index.scss 1:9 root stylesheet\n *\n * @todo: update all outdated scss imports to use @use instead of @import. Then, we can remove this.\n */\n silenceDeprecations: [...(nextConfig.sassOptions?.silenceDeprecations || []), 'import'],\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev for two reasons:\n *\n * 1. Performance: Fewer files to compile means faster compilation speeds.\n * 2. Turbopack support: Webpack's externals are not supported by Turbopack.\n *\n * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to\n * externalized packages that are not resolvable from the project root. So including a package like\n * \"drizzle-kit\" in here would do nothing - Next.js will ignore the rule and still bundle the package -\n * because it detects that the package is not resolvable from the project root (= not directly installed\n * by the user in their own package.json).\n *\n * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly\n * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).\n *\n *\n *\n * We should only do this during development, not build, because externalizing these packages can hurt\n * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the\n * same package.\n *\n * Example:\n * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)\n * - payload (not in bundle, external) -> installs qs-esm (external because of importer)\n * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.\n *\n * During development, these bundle size difference do not matter much, and development speed /\n * turbopack support are more important.\n */\n [\n 'payload',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/drizzle',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/payload-cloud',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n // see: https://github.com/vercel/next.js/discussions/76991\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\n * See the explanation in the serverExternalPackages section above.\n * We need to force Webpack to emit require() calls for these packages, even though they are not\n * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.\n *\n * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the\n * entry point packages, as explained in the serverExternalPackages section above.\n */\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n ],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n }\n },\n }\n\n if (nextConfig.basePath) {\n process.env.NEXT_BASE_PATH = nextConfig.basePath\n baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n const trailingSlash = nextConfig.trailingSlash === true ? 'true' : 'false'\n process.env.NEXT_TRAILING_SLASH = trailingSlash\n baseConfig.env.NEXT_TRAILING_SLASH = trailingSlash\n\n if (!supportsTurbopackBuild) {\n return withPayloadLegacy(baseConfig)\n } else {\n return {\n ...baseConfig,\n serverExternalPackages: [\n ...(baseConfig.serverExternalPackages || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n // Prevents turbopack build errors by the thread-stream package which is installed by pino\n 'pino',\n ],\n }\n }\n}\n\nexport default withPayload\n", " \n/**\n * This was taken and modified from https://github.com/getsentry/sentry-javascript/blob/15256034ee8150a5b7dcb97d23eca1a5486f0cae/packages/nextjs/src/config/util.ts\n *\n * MIT License\n *\n * Copyright (c) 2012 Functional Software, Inc. dba Sentry\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n * of the Software, and to permit persons to whom the Software is furnished to do\n * so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { readFileSync } from 'fs'\nimport { fileURLToPath } from 'url'\n\n/**\n * @param {string | undefined} input\n * @returns {number}\n */\nfunction _parseInt(input) {\n return parseInt(input || '', 10)\n}\n\n/**\n * Represents Semantic Versioning object\n * @typedef {Object} SemVer\n * @property {string} [buildmetadata]\n * @property {number} [canaryVersion] - undefined if not a canary version\n * @property {number} [major]\n * @property {number} [minor]\n * @property {number} [patch]\n * @property {string} [prerelease]\n */\n\n// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string\nconst SEMVER_REGEXP =\n /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*))*))?(?:\\+([0-9a-z-]+(?:\\.[0-9a-z-]+)*))?$/i\n\n/**\n * Parses input into a SemVer interface\n * @param {string} input - string representation of a semver version\n * @returns {SemVer}\n */\nexport function parseSemver(input) {\n const match = input.match(SEMVER_REGEXP) || []\n const major = _parseInt(match[1])\n const minor = _parseInt(match[2])\n const patch = _parseInt(match[3])\n\n const prerelease = match[4]\n const canaryVersion = prerelease?.startsWith('canary.')\n ? parseInt(prerelease.split('.')[1] || '0', 10)\n : undefined\n\n return {\n buildmetadata: match[5],\n canaryVersion,\n major: isNaN(major) ? undefined : major,\n minor: isNaN(minor) ? undefined : minor,\n patch: isNaN(patch) ? undefined : patch,\n prerelease: match[4],\n }\n}\n\n/**\n * Returns the version of Next.js installed in the project, or undefined if it cannot be determined.\n * @returns {SemVer | undefined}\n */\nexport function getNextjsVersion() {\n try {\n /** @type {string} */\n let pkgPath\n\n // Check if we're in ESM or CJS environment\n if (typeof import.meta?.resolve === 'function') {\n // ESM environment - use import.meta.resolve\n const pkgUrl = import.meta.resolve('next/package.json')\n // Use fileURLToPath for proper cross-platform path handling (Windows, macOS, Linux)\n // new URL().pathname returns '/C:/path' on Windows which causes path resolution issues\n pkgPath = fileURLToPath(pkgUrl)\n } else {\n // CJS environment - use require.resolve\n pkgPath = require.resolve('next/package.json')\n }\n\n const pkgJson = JSON.parse(readFileSync(pkgPath, 'utf8'))\n return parseSemver(pkgJson.version)\n } catch (e) {\n console.error('Payload: Error getting Next.js version', e)\n return undefined\n }\n}\n\n/**\n * Checks if the current Next.js version supports the `experimental.serverFastRefresh` option.\n * This was introduced in Next.js v16.2.2\n * @param {SemVer | undefined} version\n * @returns {boolean}\n */\nexport function supportsServerFastRefreshConfig(version) {\n if (!version) {\n return false\n }\n\n const { major, minor, patch } = version\n\n if (major === undefined || minor === undefined || patch === undefined) {\n return false\n }\n\n if (major > 16) {\n return true\n }\n\n if (major === 16) {\n if (minor > 2) {\n return true\n }\n if (minor === 2) {\n return patch >= 2\n }\n }\n\n return false\n}\n\n/**\n * Checks if the current Next.js version supports Turbopack externalize transitive dependencies.\n * This was introduced in Next.js v16.1.0-canary.3\n * @param {SemVer | undefined} version\n * @returns {boolean}\n */\nexport function supportsTurbopackExternalizeTransitiveDependencies(version) {\n if (!version) {\n return false\n }\n\n const { canaryVersion, major, minor, patch } = version\n\n if (major === undefined || minor === undefined) {\n return false\n }\n\n if (major > 16) {\n return true\n }\n\n if (major === 16) {\n if (minor > 1) {\n return true\n }\n if (minor === 1) {\n // 16.1.1+ and canaries support this feature\n if (patch > 0) {\n return true\n }\n if (canaryVersion !== undefined) {\n // 16.1.0-canary.3+\n return canaryVersion >= 3\n } else {\n // Next.js 16.1.0\n return true\n }\n }\n }\n\n return false\n}\n", "/**\n * Applies config options required to support Next.js versions before 16.1.0 and 16.1.0-canary.3.\n * @param {import('next').NextConfig} nextConfig\n * @returns {import('next').NextConfig}\n */\nexport const withPayloadLegacy = (nextConfig = {}) => {\n if (process.env.PAYLOAD_PATCH_TURBOPACK_WARNINGS !== 'false') {\n // TODO: This warning is thrown because we cannot externalize the entry-point package for client-s3, so we patch the warning to not show it.\n // We can remove this once Next.js implements https://github.com/vercel/next.js/discussions/76991\n const turbopackWarningText =\n 'Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.\\nTry to install it into the project directory by running'\n\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const turbopackConfigWarningText = \"Unrecognized key(s) in object: 'turbopack'\"\n\n const consoleWarn = console.warn\n console.warn = (...args) => {\n // Force to disable serverExternalPackages warnings: https://github.com/vercel/next.js/issues/68805\n if (\n (typeof args[1] === 'string' && args[1].includes(turbopackWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackWarningText))\n ) {\n return\n }\n\n // Add Payload-specific message after turbopack config warning in Next.js 15.2.x or lower.\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const hasTurbopackConfigWarning =\n (typeof args[1] === 'string' && args[1].includes(turbopackConfigWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackConfigWarningText))\n\n if (hasTurbopackConfigWarning) {\n consoleWarn(...args)\n consoleWarn(\n 'Payload: You can safely ignore the \"Invalid next.config\" warning above. This only occurs on Next.js 15.2.x or lower. We recommend upgrading to the latest supported Next.js version to resolve this warning.',\n )\n return\n }\n\n consoleWarn(...args)\n }\n }\n\n const isBuild = process.env.NODE_ENV === 'production'\n const isTurbopackNextjs15 = process.env.TURBOPACK === '1'\n const isTurbopackNextjs16 = process.env.TURBOPACK === 'auto'\n\n if (isBuild && (isTurbopackNextjs15 || isTurbopackNextjs16)) {\n throw new Error(\n 'Payload: Your Next.js version does not support using Turbopack for production builds. The *minimum* Next.js version required for Turbopack Builds is 16.1.0. Please upgrade to the latest supported Next.js version to resolve this error.',\n )\n }\n\n /** @type {import('next').NextConfig} */\n const toReturn = {\n ...nextConfig,\n serverExternalPackages: [\n // serverExternalPackages = webpack.externals, but with turbopack support and an additional check\n // for whether the package is resolvable from the project root\n ...(nextConfig.serverExternalPackages || []),\n // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.\n '@sentry/nextjs',\n ],\n }\n\n return toReturn\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;AC2BA,gBAA6B;AAC7B,iBAA8B;AA3B9B;AAiCA,SAASA,UAAUC,OAAK;AACtB,SAAOC,SAASD,SAAS,IAAI,EAAA;AAC/B;AAcA,IAAME,gBACJ;AAOK,SAASC,YAAYH,OAAK;AAC/B,QAAMI,QAAQJ,MAAMI,MAAMF,aAAA,KAAkB,CAAA;AAC5C,QAAMG,QAAQN,UAAUK,MAAM,CAAA,CAAE;AAChC,QAAME,QAAQP,UAAUK,MAAM,CAAA,CAAE;AAChC,QAAMG,QAAQR,UAAUK,MAAM,CAAA,CAAE;AAEhC,QAAMI,aAAaJ,MAAM,CAAA;AACzB,QAAMK,gBAAgBD,YAAYE,WAAW,SAAA,IACzCT,SAASO,WAAWG,MAAM,GAAA,EAAK,CAAA,KAAM,KAAK,EAAA,IAC1CC;AAEJ,SAAO;IACLC,eAAeT,MAAM,CAAA;IACrBK;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;;;YAoBjDC,MAAM;UACR;QACF;MACF;IACF;EACF;AAEA,MAAIhD,WAAWiD,UAAU;AACvBf,YAAQ1B,IAAI0C,iBAAiBlD,WAAWiD;AACxCzB,eAAWhB,IAAI0C,iBAAiBlD,WAAWiD;EAC7C;AAEA,QAAME,gBAAgBnD,WAAWmD,kBAAkB,OAAO,SAAS;AACnEjB,UAAQ1B,IAAI4C,sBAAsBD;AAClC3B,aAAWhB,IAAI4C,sBAAsBD;AAErC,MAAI,CAAC/C,wBAAwB;AAC3B,WAAOiD,kBAAkB7B,UAAA;EAC3B,OAAO;AACL,WAAO;MACL,GAAGA;MACHS,wBAAwB;QAAA,GAClBT,WAAWS,0BAA0B,CAAA;QACzC;QACA;QACA;QACA;QACA;QACA;;QAEA;MAAA;IAEJ;EACF;AACF;AAEA,IAAA,sBAAelC;",
6
+ "names": ["_parseInt", "input", "parseInt", "SEMVER_REGEXP", "parseSemver", "match", "major", "minor", "patch", "prerelease", "canaryVersion", "startsWith", "split", "undefined", "buildmetadata", "isNaN", "getNextjsVersion", "pkgPath", "import", "resolve", "pkgUrl", "fileURLToPath", "require", "pkgJson", "JSON", "parse", "readFileSync", "version", "e", "console", "error", "supportsServerFastRefreshConfig", "supportsTurbopackExternalizeTransitiveDependencies", "withPayloadLegacy", "nextConfig", "process", "env", "PAYLOAD_PATCH_TURBOPACK_WARNINGS", "turbopackWarningText", "turbopackConfigWarningText", "consoleWarn", "console", "warn", "args", "includes", "hasTurbopackConfigWarning", "isBuild", "NODE_ENV", "isTurbopackNextjs15", "TURBOPACK", "isTurbopackNextjs16", "Error", "toReturn", "serverExternalPackages", "poweredByHeader", "key", "value", "withPayload", "nextConfig", "options", "nextjsVersion", "getNextjsVersion", "supportsTurbopackBuild", "supportsTurbopackExternalizeTransitiveDependencies", "hasServerFastRefreshConfigOption", "supportsServerFastRefreshConfig", "env", "experimental", "staleTimes", "dynamic", "console", "warn", "NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH", "cacheComponents", "PAYLOAD_CACHE_COMPONENTS_ENABLED", "major", "consoleWarn", "sassWarningTexts", "args", "some", "text", "includes", "baseConfig", "turbopackServerFastRefresh", "sassOptions", "silenceDeprecations", "outputFileTracingExcludes", "turbopack", "headers", "headersFromConfig", "source", "serverExternalPackages", "process", "NODE_ENV", "devBundleServerPackages", "webpack", "webpackConfig", "webpackOptions", "incomingWebpackConfig", "externals", "plugins", "IgnorePlugin", "resourceRegExp", "resolve", "alias", "fallback", "aws4", "basePath", "NEXT_BASE_PATH", "trailingSlash", "NEXT_TRAILING_SLASH", "withPayloadLegacy"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handleAuthRedirect.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAuthRedirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAKxC,KAAK,IAAI,GAAG;IACV,MAAM,MAAA;IACN,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;IAClD,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,kBAAkB,0CAA2C,IAAI,KAAG,MAkChF,CAAA"}
1
+ {"version":3,"file":"handleAuthRedirect.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAuthRedirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAKxC,KAAK,IAAI,GAAG;IACV,MAAM,MAAA;IACN,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAA;IAClD,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,kBAAkB,0CAA2C,IAAI,KAAG,MAuChF,CAAA"}
@@ -20,7 +20,10 @@ export const handleAuthRedirect = ({
20
20
  if (searchParams && 'redirect' in searchParams) {
21
21
  delete searchParams.redirect;
22
22
  }
23
- const redirectRoute = (route !== adminRoute ? route : '') + (Object.keys(searchParams ?? {}).length > 0 ? `${qs.stringify(searchParams, {
23
+ const redirectRoute = (route !== adminRoute ? formatAdminURL({
24
+ adminRoute: '/',
25
+ path: route
26
+ }) : '') + (Object.keys(searchParams ?? {}).length > 0 ? `${qs.stringify(searchParams, {
24
27
  addQueryPrefix: true
25
28
  })}` : '');
26
29
  const redirectTo = formatAdminURL({
@@ -1 +1 @@
1
- {"version":3,"file":"handleAuthRedirect.js","names":["formatAdminURL","qs","handleAuthRedirect","config","route","searchParams","user","admin","routes","login","loginRouteFromConfig","unauthorized","unauthorizedRoute","adminRoute","redirect","redirectRoute","Object","keys","length","stringify","addQueryPrefix","redirectTo","path","parsedLoginRouteSearchParams","parse","split","searchParamsWithRedirect"],"sources":["../../src/utilities/handleAuthRedirect.ts"],"sourcesContent":["import type { TypedUser } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\n\ntype Args = {\n config\n route: string\n searchParams: { [key: string]: string | string[] }\n user?: TypedUser\n}\n\nexport const handleAuthRedirect = ({ config, route, searchParams, user }: Args): string => {\n const {\n admin: {\n routes: { login: loginRouteFromConfig, unauthorized: unauthorizedRoute },\n },\n routes: { admin: adminRoute },\n } = config\n\n if (searchParams && 'redirect' in searchParams) {\n delete searchParams.redirect\n }\n\n const redirectRoute =\n (route !== adminRoute ? route : '') +\n (Object.keys(searchParams ?? {}).length > 0\n ? `${qs.stringify(searchParams, { addQueryPrefix: true })}`\n : '')\n\n const redirectTo = formatAdminURL({\n adminRoute,\n path: user ? unauthorizedRoute : loginRouteFromConfig,\n })\n\n const parsedLoginRouteSearchParams = qs.parse(redirectTo.split('?')[1] ?? '')\n\n const searchParamsWithRedirect = `${qs.stringify(\n {\n ...parsedLoginRouteSearchParams,\n ...(redirect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CAAWI,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,GAAGC,wBAAA,EAA0B;AACpE","ignoreList":[]}
1
+ {"version":3,"file":"handleAuthRedirect.js","names":["formatAdminURL","qs","handleAuthRedirect","config","route","searchParams","user","admin","routes","login","loginRouteFromConfig","unauthorized","unauthorizedRoute","adminRoute","redirect","redirectRoute","path","Object","keys","length","stringify","addQueryPrefix","redirectTo","parsedLoginRouteSearchParams","parse","split","searchParamsWithRedirect"],"sources":["../../src/utilities/handleAuthRedirect.ts"],"sourcesContent":["import type { TypedUser } from 'payload'\n\nimport { formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\n\ntype Args = {\n config\n route: string\n searchParams: { [key: string]: string | string[] }\n user?: TypedUser\n}\n\nexport const handleAuthRedirect = ({ config, route, searchParams, user }: Args): string => {\n const {\n admin: {\n routes: { login: loginRouteFromConfig, unauthorized: unauthorizedRoute },\n },\n routes: { admin: adminRoute },\n } = config\n\n if (searchParams && 'redirect' in searchParams) {\n delete searchParams.redirect\n }\n\n const redirectRoute =\n (route !== adminRoute\n ? formatAdminURL({\n adminRoute: '/',\n path: route as `/${string}`,\n })\n : '') +\n (Object.keys(searchParams ?? {}).length > 0\n ? `${qs.stringify(searchParams, { addQueryPrefix: true })}`\n : '')\n\n const redirectTo = formatAdminURL({\n adminRoute,\n path: user ? unauthorizedRoute : loginRouteFromConfig,\n })\n\n const parsedLoginRouteSearchParams = qs.parse(redirectTo.split('?')[1] ?? '')\n\n const searchParamsWithRedirect = `${qs.stringify(\n {\n ...parsedLoginRouteSearchParams,\n ...(redirectRoute ? { redirect: redirectRoute } : {}),\n },\n { addQueryPrefix: true },\n )}`\n\n return `${redirectTo.split('?', 1)[0]}${searchParamsWithRedirect}`\n}\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,YAAYC,EAAA,MAAQ;AASpB,OAAO,MAAMC,kBAAA,GAAqBA,CAAC;EAAEC,MAAM;EAAEC,KAAK;EAAEC,YAAY;EAAEC;AAAI,CAAQ;EAC5E,MAAM;IACJC,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,KAAA,EAAOC,oBAAoB;QAAEC,YAAA,EAAcC;MAAiB;IAAE,CACzE;IACDJ,MAAA,EAAQ;MAAED,KAAA,EAAOM;IAAU;EAAE,CAC9B,GAAGV,MAAA;EAEJ,IAAIE,YAAA,IAAgB,cAAcA,YAAA,EAAc;IAC9C,OAAOA,YAAA,CAAaS,QAAQ;EAC9B;EAEA,MAAMC,aAAA,GACJ,CAACX,KAAA,KAAUS,UAAA,GACPb,cAAA,CAAe;IACba,UAAA,EAAY;IACZG,IAAA,EAAMZ;EACR,KACA,EAAC,KACJa,MAAA,CAAOC,IAAI,CAACb,YAAA,IAAgB,CAAC,GAAGc,MAAM,GAAG,IACtC,GAAGlB,EAAA,CAAGmB,SAAS,CAACf,YAAA,EAAc;IAAEgB,cAAA,EAAgB;EAAK,IAAI,GACzD,EAAC;EAEP,MAAMC,UAAA,GAAatB,cAAA,CAAe;IAChCa,UAAA;IACAG,IAAA,EAAMV,IAAA,GAAOM,iBAAA,GAAoBF;EACnC;EAEA,MAAMa,4BAAA,GAA+BtB,EAAA,CAAGuB,KAAK,CAACF,UAAA,CAAWG,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI;EAE1E,MAAMC,wBAAA,GAA2B,GAAGzB,EAAA,CAAGmB,SAAS,CAC9C;IACE,GAAGG,4BAA4B;IAC/B,IAAIR,aAAA,GAAgB;MAAED,QAAA,EAAUC;IAAc,IAAI,CAAC,CAAC;EACtD,GACA;IAAEM,cAAA,EAAgB;EAAK,IACtB;EAEH,OAAO,GAAGC,UAAA,CAAWG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,GAAGC,wBAAA,EAA0B;AACpE","ignoreList":[]}
@@ -0,0 +1,52 @@
1
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
2
+ import { handleAuthRedirect } from './handleAuthRedirect.js';
3
+ describe('handleAuthRedirect', () => {
4
+ const config = {
5
+ admin: {
6
+ routes: {
7
+ login: '/login',
8
+ unauthorized: '/unauthorized'
9
+ }
10
+ },
11
+ routes: {
12
+ admin: '/admin'
13
+ }
14
+ };
15
+ const originalTrailingSlash = process.env.NEXT_TRAILING_SLASH;
16
+ beforeEach(() => {
17
+ process.env.NEXT_TRAILING_SLASH = 'true';
18
+ });
19
+ afterEach(() => {
20
+ if (originalTrailingSlash === undefined) {
21
+ delete process.env.NEXT_TRAILING_SLASH;
22
+ } else {
23
+ process.env.NEXT_TRAILING_SLASH = originalTrailingSlash;
24
+ }
25
+ });
26
+ it('should use a canonical trailing-slash path in the redirect query', () => {
27
+ const result = handleAuthRedirect({
28
+ config,
29
+ route: '/admin/collections/posts',
30
+ searchParams: {}
31
+ });
32
+ expect(result).toBe('/admin/login/?redirect=%2Fadmin%2Fcollections%2Fposts%2F');
33
+ });
34
+ it('should not add a redirect query for the admin dashboard', () => {
35
+ const result = handleAuthRedirect({
36
+ config,
37
+ route: '/admin',
38
+ searchParams: {}
39
+ });
40
+ expect(result).toBe('/admin/login/');
41
+ });
42
+ it('should preserve non-trailing-slash URLs when trailing slashes are disabled', () => {
43
+ process.env.NEXT_TRAILING_SLASH = 'false';
44
+ const result = handleAuthRedirect({
45
+ config,
46
+ route: '/admin/collections/posts',
47
+ searchParams: {}
48
+ });
49
+ expect(result).toBe('/admin/login?redirect=%2Fadmin%2Fcollections%2Fposts');
50
+ });
51
+ });
52
+ //# sourceMappingURL=handleAuthRedirect.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleAuthRedirect.spec.js","names":["afterEach","beforeEach","describe","expect","it","handleAuthRedirect","config","admin","routes","login","unauthorized","originalTrailingSlash","process","env","NEXT_TRAILING_SLASH","undefined","result","route","searchParams","toBe"],"sources":["../../src/utilities/handleAuthRedirect.spec.ts"],"sourcesContent":["import { afterEach, beforeEach, describe, expect, it } from 'vitest'\n\nimport { handleAuthRedirect } from './handleAuthRedirect.js'\n\ndescribe('handleAuthRedirect', () => {\n const config = {\n admin: {\n routes: {\n login: '/login',\n unauthorized: '/unauthorized',\n },\n },\n routes: {\n admin: '/admin',\n },\n }\n\n const originalTrailingSlash = process.env.NEXT_TRAILING_SLASH\n\n beforeEach(() => {\n process.env.NEXT_TRAILING_SLASH = 'true'\n })\n\n afterEach(() => {\n if (originalTrailingSlash === undefined) {\n delete process.env.NEXT_TRAILING_SLASH\n } else {\n process.env.NEXT_TRAILING_SLASH = originalTrailingSlash\n }\n })\n\n it('should use a canonical trailing-slash path in the redirect query', () => {\n const result = handleAuthRedirect({\n config,\n route: '/admin/collections/posts',\n searchParams: {},\n })\n\n expect(result).toBe('/admin/login/?redirect=%2Fadmin%2Fcollections%2Fposts%2F')\n })\n\n it('should not add a redirect query for the admin dashboard', () => {\n const result = handleAuthRedirect({\n config,\n route: '/admin',\n searchParams: {},\n })\n\n expect(result).toBe('/admin/login/')\n })\n\n it('should preserve non-trailing-slash URLs when trailing slashes are disabled', () => {\n process.env.NEXT_TRAILING_SLASH = 'false'\n\n const result = handleAuthRedirect({\n config,\n route: '/admin/collections/posts',\n searchParams: {},\n })\n\n expect(result).toBe('/admin/login?redirect=%2Fadmin%2Fcollections%2Fposts')\n })\n})\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAE5D,SAASC,kBAAkB,QAAQ;AAEnCH,QAAA,CAAS,sBAAsB;EAC7B,MAAMI,MAAA,GAAS;IACbC,KAAA,EAAO;MACLC,MAAA,EAAQ;QACNC,KAAA,EAAO;QACPC,YAAA,EAAc;MAChB;IACF;IACAF,MAAA,EAAQ;MACND,KAAA,EAAO;IACT;EACF;EAEA,MAAMI,qBAAA,GAAwBC,OAAA,CAAQC,GAAG,CAACC,mBAAmB;EAE7Db,UAAA,CAAW;IACTW,OAAA,CAAQC,GAAG,CAACC,mBAAmB,GAAG;EACpC;EAEAd,SAAA,CAAU;IACR,IAAIW,qBAAA,KAA0BI,SAAA,EAAW;MACvC,OAAOH,OAAA,CAAQC,GAAG,CAACC,mBAAmB;IACxC,OAAO;MACLF,OAAA,CAAQC,GAAG,CAACC,mBAAmB,GAAGH,qBAAA;IACpC;EACF;EAEAP,EAAA,CAAG,oEAAoE;IACrE,MAAMY,MAAA,GAASX,kBAAA,CAAmB;MAChCC,MAAA;MACAW,KAAA,EAAO;MACPC,YAAA,EAAc,CAAC;IACjB;IAEAf,MAAA,CAAOa,MAAA,EAAQG,IAAI,CAAC;EACtB;EAEAf,EAAA,CAAG,2DAA2D;IAC5D,MAAMY,MAAA,GAASX,kBAAA,CAAmB;MAChCC,MAAA;MACAW,KAAA,EAAO;MACPC,YAAA,EAAc,CAAC;IACjB;IAEAf,MAAA,CAAOa,MAAA,EAAQG,IAAI,CAAC;EACtB;EAEAf,EAAA,CAAG,8EAA8E;IAC/EQ,OAAA,CAAQC,GAAG,CAACC,mBAAmB,GAAG;IAElC,MAAME,MAAA,GAASX,kBAAA,CAAmB;MAChCC,MAAA;MACAW,KAAA,EAAO;MACPC,YAAA,EAAc,CAAC;IACjB;IAEAf,MAAA,CAAOa,MAAA,EAAQG,IAAI,CAAC;EACtB;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Root/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,KAAK,EAIV,SAAS,EAET,eAAe,EAEhB,MAAM,SAAS,CAAA;AAShB,OAAO,KAAK,MAAM,OAAO,CAAA;AAYzB,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE;IACxC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE;QAA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C7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;QACvB,QAAQ,EAAE,MAAM,EAAE,CAAA;KACnB,CAAC,CAAA;IACF,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;QAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;KACjC,CAAC,CAAA;CACH,+BAkUA,CAAA"}
@@ -4,7 +4,7 @@ import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerCompo
4
4
  import { getVisibleEntities } from '@payloadcms/ui/shared';
5
5
  import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
6
6
  import { notFound, redirect } from 'next/navigation.js';
7
- import { applyLocaleFiltering, formatAdminURL } from 'payload/shared';
7
+ import { applyLocaleFiltering, formatAdminURL, stripTrailingSlash } from 'payload/shared';
8
8
  import * as qs from 'qs-esm';
9
9
  import React from 'react';
10
10
  import { DefaultTemplate } from '../../templates/Default/index.js';
@@ -34,11 +34,17 @@ export const RootPage = async ({
34
34
  admin: adminRoute
35
35
  }
36
36
  } = config;
37
+ const adminRouteURL = formatAdminURL({
38
+ adminRoute
39
+ });
37
40
  const params = await paramsPromise;
38
- const currentRoute = formatAdminURL({
41
+ // route with possible trailing slash
42
+ const currentRouteURL = formatAdminURL({
39
43
  adminRoute,
40
44
  path: Array.isArray(params.segments) ? `/${params.segments.join('/')}` : null
41
45
  });
46
+ // route without possible trailing slash
47
+ const currentRouteToCompare = stripTrailingSlash(currentRouteURL);
42
48
  const segments = Array.isArray(params.segments) ? params.segments : [];
43
49
  const isCollectionRoute = segments[0] === 'collections';
44
50
  const isGlobalRoute = segments[0] === 'globals';
@@ -56,7 +62,7 @@ export const RootPage = async ({
56
62
  });
57
63
  // Only redirect if there's NO custom view configured for /collections
58
64
  if (!viewKey) {
59
- redirect(adminRoute);
65
+ redirect(adminRouteURL);
60
66
  }
61
67
  }
62
68
  if (segments[1]) {
@@ -76,7 +82,7 @@ export const RootPage = async ({
76
82
  });
77
83
  // Only redirect if there's NO custom view configured for /globals
78
84
  if (!viewKey) {
79
- redirect(adminRoute);
85
+ redirect(adminRouteURL);
80
86
  }
81
87
  }
82
88
  if (segments[1]) {
@@ -113,21 +119,21 @@ export const RootPage = async ({
113
119
  })
114
120
  },
115
121
  // intentionally omit `serverURL` to keep URL relative
116
- urlSuffix: `${currentRoute}${searchParams ? queryString : ''}`
122
+ urlSuffix: `${currentRouteURL}${searchParams ? queryString : ''}`
117
123
  }
118
124
  });
119
125
  if (!permissions.canAccessAdmin && !isPublicAdminRoute({
120
126
  adminRoute,
121
127
  config: payload.config,
122
- route: currentRoute
128
+ route: currentRouteToCompare
123
129
  }) && !isCustomAdminView({
124
130
  adminRoute,
125
131
  config: payload.config,
126
- route: currentRoute
132
+ route: currentRouteToCompare
127
133
  })) {
128
134
  redirect(handleAuthRedirect({
129
135
  config: payload.config,
130
- route: currentRoute,
136
+ route: currentRouteToCompare,
131
137
  searchParams,
132
138
  user: userWithReadAccess
133
139
  }));
@@ -155,7 +161,7 @@ export const RootPage = async ({
155
161
  adminRoute,
156
162
  collectionConfig,
157
163
  collectionPreferences,
158
- currentRoute,
164
+ currentRoute: currentRouteToCompare,
159
165
  globalConfig,
160
166
  payload,
161
167
  searchParams,
@@ -175,28 +181,29 @@ export const RootPage = async ({
175
181
  notFound();
176
182
  }
177
183
  if (dbHasUser) {
178
- redirect(adminRoute);
184
+ redirect(adminRouteURL);
179
185
  }
180
186
  }
181
187
  const usersCollection = config.collections.find(({
182
188
  slug
183
189
  }) => slug === userSlug);
184
190
  const disableLocalStrategy = usersCollection?.auth?.disableLocalStrategy;
185
- const createFirstUserRoute = formatAdminURL({
191
+ const rawCreateFirstUserRoute = formatAdminURL({
186
192
  adminRoute,
187
193
  path: _createFirstUserRoute
188
194
  });
189
- if (disableLocalStrategy && currentRoute === createFirstUserRoute) {
190
- redirect(adminRoute);
195
+ const createFirstUserRoute = stripTrailingSlash(rawCreateFirstUserRoute);
196
+ if (disableLocalStrategy && currentRouteToCompare === createFirstUserRoute) {
197
+ redirect(adminRouteURL);
191
198
  }
192
- if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {
193
- redirect(createFirstUserRoute);
199
+ if (!dbHasUser && currentRouteToCompare !== createFirstUserRoute && !disableLocalStrategy) {
200
+ redirect(rawCreateFirstUserRoute);
194
201
  }
195
- if (dbHasUser && currentRoute === createFirstUserRoute) {
196
- redirect(adminRoute);
202
+ if (dbHasUser && currentRouteToCompare === createFirstUserRoute) {
203
+ redirect(adminRouteURL);
197
204
  }
198
205
  if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {
199
- redirect(adminRoute);
206
+ redirect(adminRouteURL);
200
207
  }
201
208
  const clientConfig = getClientConfig({
202
209
  config,
@@ -211,7 +218,7 @@ export const RootPage = async ({
211
218
  });
212
219
  // Ensure locale on req is still valid after filtering locales
213
220
  if (clientConfig.localization && req.locale && !clientConfig.localization.localeCodes.includes(req.locale)) {
214
- redirect(`${currentRoute}${qs.stringify({
221
+ redirect(`${currentRouteURL}${qs.stringify({
215
222
  ...searchParams,
216
223
  locale: clientConfig.localization.localeCodes.includes(clientConfig.localization.defaultLocale) ? clientConfig.localization.defaultLocale : clientConfig.localization.localeCodes[0]
217
224
  }, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["PageConfigProvider","RenderServerComponent","getVisibleEntities","getClientConfig","notFound","redirect","applyLocaleFiltering","formatAdminURL","qs","React","DefaultTemplate","MinimalTemplate","getPreferences","handleAuthRedirect","initReq","isCustomAdminView","isPublicAdminRoute","getCustomViewByRoute","getRouteData","RootPage","config","configPromise","importMap","params","paramsPromise","searchParams","searchParamsPromise","admin","routes","createFirstUser","_createFirstUserRoute","user","userSlug","adminRoute","currentRoute","path","Array","isArray","segments","join","isCollectionRoute","isGlobalRoute","collectionConfig","undefined","globalConfig","length","viewKey","collections","find","slug","globals","queryString","stringify","addQueryPrefix","cookies","locale","permissions","req","payload","userWithReadAccess","key","overrides","fallbackLocale","query","parse","depth","ignoreQueryPrefix","urlSuffix","canAccessAdmin","route","collectionPreferences","folders","id","then","res","value","browseByFolderSlugs","DefaultView","documentSubViewType","routeParams","templateClassName","templateType","viewActions","viewType","dbHasUser","db","findOne","collection","doc","Component","payloadComponent","usersCollection","disableLocalStrategy","auth","createFirstUserRoute","clientConfig","i18n","localization","localeCodes","includes","defaultLocale","visibleEntities","folderID","RenderedView","clientProps","collectionSlug","docID","globalSlug","Fallback","serverProps","initPageResult","languageOptions","Object","entries","supportedLanguages","reduce","acc","language","languageConfig","keys","push","label","translations","general","thisLanguage","_jsxs","_jsx","Fragment","className"],"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type {\n AdminViewClientProps,\n AdminViewServerPropsOnly,\n CollectionPreferences,\n ImportMap,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { PageConfigProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getVisibleEntities } from '@payloadcms/ui/shared'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { applyLocaleFiltering, formatAdminURL } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React from 'react'\n\nimport { DefaultTemplate } from '../../templates/Default/index.js'\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { handleAuthRedirect } from '../../utilities/handleAuthRedirect.js'\nimport { initReq } from '../../utilities/initReq.js'\nimport { isCustomAdminView } from '../../utilities/isCustomAdminView.js'\nimport { isPublicAdminRoute } from '../../utilities/isPublicAdminRoute.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { getRouteData } from './getRouteData.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n importMap,\n params: paramsPromise,\n searchParams: searchParamsPromise,\n}: {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: _createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n\n const params = await paramsPromise\n\n const currentRoute = formatAdminURL({\n adminRoute,\n path: Array.isArray(params.segments) ? `/${params.segments.join('/')}` : null,\n })\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n const isCollectionRoute = segments[0] === 'collections'\n const isGlobalRoute = segments[0] === 'globals'\n let collectionConfig: SanitizedCollectionConfig = undefined\n let globalConfig: SanitizedGlobalConfig = undefined\n\n const searchParams = await searchParamsPromise\n\n // Redirect `${adminRoute}/collections` to `${adminRoute}`\n if (isCollectionRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/collections',\n })\n\n // Only redirect if there's NO custom view configured for /collections\n if (!viewKey) {\n redirect(adminRoute)\n }\n }\n\n if (segments[1]) {\n collectionConfig = config.collections.find(({ slug }) => slug === segments[1])\n }\n }\n\n // Redirect `${adminRoute}/globals` to `${adminRoute}`\n if (isGlobalRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/globals',\n })\n\n // Only redirect if there's NO custom view configured for /globals\n if (!viewKey) {\n redirect(adminRoute)\n }\n }\n\n if (segments[1]) {\n globalConfig = config.globals.find(({ slug }) => slug === segments[1])\n }\n }\n\n if ((isCollectionRoute && !collectionConfig) || (isGlobalRoute && !globalConfig)) {\n return notFound()\n }\n\n const queryString = `${qs.stringify(searchParams ?? {}, { addQueryPrefix: true })}`\n\n const {\n cookies,\n locale,\n permissions,\n req,\n req: { payload },\n user: userWithReadAccess,\n } = await initReq({\n configPromise: config,\n importMap,\n key: 'initPage',\n overrides: {\n fallbackLocale: false,\n req: {\n query: qs.parse(queryString, {\n depth: 10,\n ignoreQueryPrefix: true,\n }),\n },\n // intentionally omit `serverURL` to keep URL relative\n urlSuffix: `${currentRoute}${searchParams ? queryString : ''}`,\n },\n })\n\n if (\n !permissions.canAccessAdmin &&\n !isPublicAdminRoute({ adminRoute, config: payload.config, route: currentRoute }) &&\n !isCustomAdminView({ adminRoute, config: payload.config, route: currentRoute })\n ) {\n redirect(\n handleAuthRedirect({\n config: payload.config,\n route: currentRoute,\n searchParams,\n user: userWithReadAccess,\n }),\n )\n }\n\n let collectionPreferences: CollectionPreferences = undefined\n\n if (collectionConfig && segments.length === 2) {\n if (config.folders && collectionConfig.folders && segments[1] !== config.folders.slug) {\n await getPreferences<CollectionPreferences>(\n `collection-${collectionConfig.slug}`,\n req.payload,\n req.user.id,\n config.admin.user,\n ).then((res) => {\n if (res && res.value) {\n collectionPreferences = res.value\n }\n })\n }\n }\n\n const {\n browseByFolderSlugs,\n DefaultView,\n documentSubViewType,\n routeParams,\n templateClassName,\n templateType,\n viewActions,\n viewType,\n } = getRouteData({\n adminRoute,\n collectionConfig,\n collectionPreferences,\n currentRoute,\n globalConfig,\n payload,\n searchParams,\n segments,\n })\n\n req.routeParams = routeParams\n\n const dbHasUser =\n req.user ||\n (await req.payload.db\n .findOne({\n collection: userSlug,\n req,\n })\n ?.then((doc) => !!doc))\n\n /**\n * This function is responsible for handling the case where the view is not found.\n * The current route did not match any default views or custom route views.\n */\n if (!DefaultView?.Component && !DefaultView?.payloadComponent) {\n if (req?.user) {\n notFound()\n }\n\n if (dbHasUser) {\n redirect(adminRoute)\n }\n }\n\n const usersCollection = config.collections.find(({ slug }) => slug === userSlug)\n const disableLocalStrategy = usersCollection?.auth?.disableLocalStrategy\n\n const createFirstUserRoute = formatAdminURL({\n adminRoute,\n path: _createFirstUserRoute,\n })\n\n if (disableLocalStrategy && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {\n redirect(createFirstUserRoute)\n }\n\n if (dbHasUser && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {\n redirect(adminRoute)\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: viewType === 'createFirstUser' ? true : userWithReadAccess,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n // Ensure locale on req is still valid after filtering locales\n if (\n clientConfig.localization &&\n req.locale &&\n !clientConfig.localization.localeCodes.includes(req.locale)\n ) {\n redirect(\n `${currentRoute}${qs.stringify(\n {\n ...searchParams,\n locale: clientConfig.localization.localeCodes.includes(\n clientConfig.localization.defaultLocale,\n )\n ? clientConfig.localization.defaultLocale\n : clientConfig.localization.localeCodes[0],\n },\n { addQueryPrefix: true },\n )}`,\n )\n }\n\n const visibleEntities = getVisibleEntities({ req })\n\n const folderID = routeParams.folderID\n\n const RenderedView = RenderServerComponent({\n clientProps: {\n browseByFolderSlugs,\n clientConfig,\n collectionSlug: collectionConfig?.slug,\n docID: routeParams.id,\n documentSubViewType,\n folderID,\n globalSlug: globalConfig?.slug,\n viewType,\n } satisfies AdminViewClientProps,\n Component: DefaultView.payloadComponent,\n Fallback: DefaultView.Component,\n importMap,\n serverProps: {\n clientConfig,\n collectionConfig,\n docID: routeParams.id,\n folderID,\n globalConfig,\n i18n: req.i18n,\n importMap,\n initPageResult: {\n collectionConfig,\n cookies,\n docID: routeParams.id,\n globalConfig,\n languageOptions: Object.entries(req.payload.config.i18n.supportedLanguages || {}).reduce(\n (acc, [language, languageConfig]) => {\n if (Object.keys(req.payload.config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n },\n [],\n ),\n locale,\n permissions,\n req,\n translations: req.i18n.translations,\n visibleEntities,\n },\n params,\n payload: req.payload,\n searchParams,\n user: userWithReadAccess,\n viewActions,\n } satisfies AdminViewServerPropsOnly,\n })\n\n return (\n <PageConfigProvider config={clientConfig}>\n {!templateType && <React.Fragment>{RenderedView}</React.Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n collectionSlug={collectionConfig?.slug}\n docID={routeParams.id}\n documentSubViewType={documentSubViewType}\n globalSlug={globalConfig?.slug}\n i18n={req.i18n}\n locale={locale}\n params={params}\n payload={req.payload}\n permissions={permissions}\n req={req}\n searchParams={searchParams}\n user={userWithReadAccess}\n viewActions={viewActions}\n viewType={viewType}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: visibleEntities?.collections,\n globals: visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </PageConfigProvider>\n )\n}\n"],"mappings":";AAYA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,oBAAoB,EAAEC,cAAc,QAAQ;AACrD,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,MAAW;AAElB,SAASC,eAAe,QAAQ;AAChC,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,OAAO,QAAQ;AACxB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,YAAY,QAAQ;AAS7B,OAAO,MAAMC,QAAA,GAAW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EAAY/D,YAAA,EAAcK,IAAA;MAC1B+C,IAAA,EAAMvC,GAAA,CAAIuC,IAAI;MACdzC,MAAA,EAAQA,MAAA;MACRhC,MAAA,EAAQA,MAAA;MACRmC,OAAA,EAASD,GAAA,CAAIC,OAAO;MACpBF,WAAA,EAAaA,WAAA;MACbC,GAAA,EAAKA,GAAA;MACLhC,YAAA,EAAcA,YAAA;MACdM,IAAA,EAAM4B,kBAAA;MACNuB,WAAA,EAAaA,WAAA;MACbC,QAAA,EAAUA,QAAA;MACVkB,eAAA,EAAiB;QACf;QACA;QACAtD,WAAA,EAAasD,eAAA,EAAiBtD,WAAA;QAC9BG,OAAA,EAASmD,eAAA,EAAiBnD;MAC5B;gBAECqD;;;AAKX","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["PageConfigProvider","RenderServerComponent","getVisibleEntities","getClientConfig","notFound","redirect","applyLocaleFiltering","formatAdminURL","stripTrailingSlash","qs","React","DefaultTemplate","MinimalTemplate","getPreferences","handleAuthRedirect","initReq","isCustomAdminView","isPublicAdminRoute","getCustomViewByRoute","getRouteData","RootPage","config","configPromise","importMap","params","paramsPromise","searchParams","searchParamsPromise","admin","routes","createFirstUser","_createFirstUserRoute","user","userSlug","adminRoute","adminRouteURL","currentRouteURL","path","Array","isArray","segments","join","currentRouteToCompare","isCollectionRoute","isGlobalRoute","collectionConfig","undefined","globalConfig","length","viewKey","currentRoute","collections","find","slug","globals","queryString","stringify","addQueryPrefix","cookies","locale","permissions","req","payload","userWithReadAccess","key","overrides","fallbackLocale","query","parse","depth","ignoreQueryPrefix","urlSuffix","canAccessAdmin","route","collectionPreferences","folders","id","then","res","value","browseByFolderSlugs","DefaultView","documentSubViewType","routeParams","templateClassName","templateType","viewActions","viewType","dbHasUser","db","findOne","collection","doc","Component","payloadComponent","usersCollection","disableLocalStrategy","auth","rawCreateFirstUserRoute","createFirstUserRoute","clientConfig","i18n","localization","localeCodes","includes","defaultLocale","visibleEntities","folderID","RenderedView","clientProps","collectionSlug","docID","globalSlug","Fallback","serverProps","initPageResult","languageOptions","Object","entries","supportedLanguages","reduce","acc","language","languageConfig","keys","push","label","translations","general","thisLanguage","_jsxs","_jsx","Fragment","className"],"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type {\n AdminViewClientProps,\n AdminViewServerPropsOnly,\n CollectionPreferences,\n ImportMap,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport { PageConfigProvider } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getVisibleEntities } from '@payloadcms/ui/shared'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { notFound, redirect } from 'next/navigation.js'\nimport { applyLocaleFiltering, formatAdminURL, stripTrailingSlash } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React from 'react'\n\nimport { DefaultTemplate } from '../../templates/Default/index.js'\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\nimport { getPreferences } from '../../utilities/getPreferences.js'\nimport { handleAuthRedirect } from '../../utilities/handleAuthRedirect.js'\nimport { initReq } from '../../utilities/initReq.js'\nimport { isCustomAdminView } from '../../utilities/isCustomAdminView.js'\nimport { isPublicAdminRoute } from '../../utilities/isPublicAdminRoute.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { getRouteData } from './getRouteData.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n importMap,\n params: paramsPromise,\n searchParams: searchParamsPromise,\n}: {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: _createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n const adminRouteURL = formatAdminURL({ adminRoute })\n\n const params = await paramsPromise\n\n // route with possible trailing slash\n const currentRouteURL = formatAdminURL({\n adminRoute,\n path: Array.isArray(params.segments) ? `/${params.segments.join('/')}` : null,\n })\n // route without possible trailing slash\n const currentRouteToCompare = stripTrailingSlash(currentRouteURL)\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n const isCollectionRoute = segments[0] === 'collections'\n const isGlobalRoute = segments[0] === 'globals'\n let collectionConfig: SanitizedCollectionConfig = undefined\n let globalConfig: SanitizedGlobalConfig = undefined\n\n const searchParams = await searchParamsPromise\n\n // Redirect `${adminRoute}/collections` to `${adminRoute}`\n if (isCollectionRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/collections',\n })\n\n // Only redirect if there's NO custom view configured for /collections\n if (!viewKey) {\n redirect(adminRouteURL)\n }\n }\n\n if (segments[1]) {\n collectionConfig = config.collections.find(({ slug }) => slug === segments[1])\n }\n }\n\n // Redirect `${adminRoute}/globals` to `${adminRoute}`\n if (isGlobalRoute) {\n if (segments.length === 1) {\n const { viewKey } = getCustomViewByRoute({\n config,\n currentRoute: '/globals',\n })\n\n // Only redirect if there's NO custom view configured for /globals\n if (!viewKey) {\n redirect(adminRouteURL)\n }\n }\n\n if (segments[1]) {\n globalConfig = config.globals.find(({ slug }) => slug === segments[1])\n }\n }\n\n if ((isCollectionRoute && !collectionConfig) || (isGlobalRoute && !globalConfig)) {\n return notFound()\n }\n\n const queryString = `${qs.stringify(searchParams ?? {}, { addQueryPrefix: true })}`\n\n const {\n cookies,\n locale,\n permissions,\n req,\n req: { payload },\n user: userWithReadAccess,\n } = await initReq({\n configPromise: config,\n importMap,\n key: 'initPage',\n overrides: {\n fallbackLocale: false,\n req: {\n query: qs.parse(queryString, {\n depth: 10,\n ignoreQueryPrefix: true,\n }),\n },\n // intentionally omit `serverURL` to keep URL relative\n urlSuffix: `${currentRouteURL}${searchParams ? queryString : ''}`,\n },\n })\n\n if (\n !permissions.canAccessAdmin &&\n !isPublicAdminRoute({ adminRoute, config: payload.config, route: currentRouteToCompare }) &&\n !isCustomAdminView({ adminRoute, config: payload.config, route: currentRouteToCompare })\n ) {\n redirect(\n handleAuthRedirect({\n config: payload.config,\n route: currentRouteToCompare,\n searchParams,\n user: userWithReadAccess,\n }),\n )\n }\n\n let collectionPreferences: CollectionPreferences = undefined\n\n if (collectionConfig && segments.length === 2) {\n if (config.folders && collectionConfig.folders && segments[1] !== config.folders.slug) {\n await getPreferences<CollectionPreferences>(\n `collection-${collectionConfig.slug}`,\n req.payload,\n req.user.id,\n config.admin.user,\n ).then((res) => {\n if (res && res.value) {\n collectionPreferences = res.value\n }\n })\n }\n }\n\n const {\n browseByFolderSlugs,\n DefaultView,\n documentSubViewType,\n routeParams,\n templateClassName,\n templateType,\n viewActions,\n viewType,\n } = getRouteData({\n adminRoute,\n collectionConfig,\n collectionPreferences,\n currentRoute: currentRouteToCompare,\n globalConfig,\n payload,\n searchParams,\n segments,\n })\n\n req.routeParams = routeParams\n\n const dbHasUser =\n req.user ||\n (await req.payload.db\n .findOne({\n collection: userSlug,\n req,\n })\n ?.then((doc) => !!doc))\n\n /**\n * This function is responsible for handling the case where the view is not found.\n * The current route did not match any default views or custom route views.\n */\n if (!DefaultView?.Component && !DefaultView?.payloadComponent) {\n if (req?.user) {\n notFound()\n }\n\n if (dbHasUser) {\n redirect(adminRouteURL)\n }\n }\n\n const usersCollection = config.collections.find(({ slug }) => slug === userSlug)\n const disableLocalStrategy = usersCollection?.auth?.disableLocalStrategy\n\n const rawCreateFirstUserRoute = formatAdminURL({\n adminRoute,\n path: _createFirstUserRoute,\n })\n const createFirstUserRoute = stripTrailingSlash(rawCreateFirstUserRoute)\n\n if (disableLocalStrategy && currentRouteToCompare === createFirstUserRoute) {\n redirect(adminRouteURL)\n }\n\n if (!dbHasUser && currentRouteToCompare !== createFirstUserRoute && !disableLocalStrategy) {\n redirect(rawCreateFirstUserRoute)\n }\n\n if (dbHasUser && currentRouteToCompare === createFirstUserRoute) {\n redirect(adminRouteURL)\n }\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {\n redirect(adminRouteURL)\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: viewType === 'createFirstUser' ? true : userWithReadAccess,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n // Ensure locale on req is still valid after filtering locales\n if (\n clientConfig.localization &&\n req.locale &&\n !clientConfig.localization.localeCodes.includes(req.locale)\n ) {\n redirect(\n `${currentRouteURL}${qs.stringify(\n {\n ...searchParams,\n locale: clientConfig.localization.localeCodes.includes(\n clientConfig.localization.defaultLocale,\n )\n ? clientConfig.localization.defaultLocale\n : clientConfig.localization.localeCodes[0],\n },\n { addQueryPrefix: true },\n )}`,\n )\n }\n\n const visibleEntities = getVisibleEntities({ req })\n\n const folderID = routeParams.folderID\n\n const RenderedView = RenderServerComponent({\n clientProps: {\n browseByFolderSlugs,\n clientConfig,\n collectionSlug: collectionConfig?.slug,\n docID: routeParams.id,\n documentSubViewType,\n folderID,\n globalSlug: globalConfig?.slug,\n viewType,\n } satisfies AdminViewClientProps,\n Component: DefaultView.payloadComponent,\n Fallback: DefaultView.Component,\n importMap,\n serverProps: {\n clientConfig,\n collectionConfig,\n docID: routeParams.id,\n folderID,\n globalConfig,\n i18n: req.i18n,\n importMap,\n initPageResult: {\n collectionConfig,\n cookies,\n docID: routeParams.id,\n globalConfig,\n languageOptions: Object.entries(req.payload.config.i18n.supportedLanguages || {}).reduce(\n (acc, [language, languageConfig]) => {\n if (Object.keys(req.payload.config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language,\n })\n }\n\n return acc\n },\n [],\n ),\n locale,\n permissions,\n req,\n translations: req.i18n.translations,\n visibleEntities,\n },\n params,\n payload: req.payload,\n searchParams,\n user: userWithReadAccess,\n viewActions,\n } satisfies AdminViewServerPropsOnly,\n })\n\n return (\n <PageConfigProvider config={clientConfig}>\n {!templateType && <React.Fragment>{RenderedView}</React.Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n collectionSlug={collectionConfig?.slug}\n docID={routeParams.id}\n documentSubViewType={documentSubViewType}\n globalSlug={globalConfig?.slug}\n i18n={req.i18n}\n locale={locale}\n params={params}\n payload={req.payload}\n permissions={permissions}\n req={req}\n searchParams={searchParams}\n user={userWithReadAccess}\n viewActions={viewActions}\n viewType={viewType}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: visibleEntities?.collections,\n globals: visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </PageConfigProvider>\n )\n}\n"],"mappings":";AAYA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,SAASC,oBAAoB,EAAEC,cAAc,EAAEC,kBAAkB,QAAQ;AACzE,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,MAAW;AAElB,SAASC,eAAe,QAAQ;AAChC,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,kBAAkB,QAAQ;AACnC,SAASC,OAAO,QAAQ;AACxB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,YAAY,QAAQ;AAS7B,OAAO,MAAMC,QAAA,GAAW,MAAAA,CAAO;EAC7BC,MAAA,EAAQC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;QAEjDvB,YAAA,KAAiB,0BAChB8C,IAAA,CAACxH,eAAA;MACCmG,cAAA,EAAgBjE,gBAAA,EAAkBQ,IAAA;MAClC0D,KAAA,EAAO5B,WAAA,CAAYP,EAAE;MACrBM,mBAAA,EAAqBA,mBAAA;MACrB8B,UAAA,EAAYjE,YAAA,EAAcM,IAAA;MAC1BgD,IAAA,EAAMxC,GAAA,CAAIwC,IAAI;MACd1C,MAAA,EAAQA,MAAA;MACRnC,MAAA,EAAQA,MAAA;MACRsC,OAAA,EAASD,GAAA,CAAIC,OAAO;MACpBF,WAAA,EAAaA,WAAA;MACbC,GAAA,EAAKA,GAAA;MACLnC,YAAA,EAAcA,YAAA;MACdM,IAAA,EAAM+B,kBAAA;MACNuB,WAAA,EAAaA,WAAA;MACbC,QAAA,EAAUA,QAAA;MACVmB,eAAA,EAAiB;QACf;QACA;QACAvD,WAAA,EAAauD,eAAA,EAAiBvD,WAAA;QAC9BG,OAAA,EAASoD,eAAA,EAAiBpD;MAC5B;gBAECsD;;;AAKX","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"isPathMatchingRoute.d.ts","sourceRoot":"","sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,gEAM7B;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,YA+BA,CAAA"}
1
+ {"version":3,"file":"isPathMatchingRoute.d.ts","sourceRoot":"","sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,gEAM7B;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,YAgCA,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { pathToRegexp } from 'path-to-regexp';
2
+ import { stripTrailingSlash } from 'payload/shared';
2
3
  export const isPathMatchingRoute = ({
3
4
  currentRoute,
4
5
  exact,
@@ -10,6 +11,7 @@ export const isPathMatchingRoute = ({
10
11
  if (!viewPath) {
11
12
  return false;
12
13
  }
14
+ const normalizedCurrentRoute = strict ? currentRoute : stripTrailingSlash(currentRoute);
13
15
  const keys = [];
14
16
  // run the view path through `pathToRegexp` to resolve any dynamic segments
15
17
  // i.e. `/admin/custom-view/:id` -> `/admin/custom-view/123`
@@ -17,16 +19,16 @@ export const isPathMatchingRoute = ({
17
19
  sensitive,
18
20
  strict
19
21
  });
20
- const match = regex.exec(currentRoute);
21
- const viewRoute = match?.[0] || viewPath;
22
+ const match = regex.exec(normalizedCurrentRoute);
23
+ const viewRoute = strict ? match?.[0] || viewPath : stripTrailingSlash(match?.[0] || viewPath);
22
24
  if (exact) {
23
- return currentRoute === viewRoute;
25
+ return normalizedCurrentRoute === viewRoute;
24
26
  }
25
27
  if (!exact) {
26
- if (!currentRoute.startsWith(viewRoute)) {
28
+ if (!normalizedCurrentRoute.startsWith(viewRoute)) {
27
29
  return false;
28
30
  }
29
- const remainingPath = currentRoute.slice(viewRoute.length);
31
+ const remainingPath = normalizedCurrentRoute.slice(viewRoute.length);
30
32
  return remainingPath === '' || remainingPath.startsWith('/');
31
33
  }
32
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"isPathMatchingRoute.js","names":["pathToRegexp","isPathMatchingRoute","currentRoute","exact","path","viewPath","sensitive","strict","keys","regex","match","exec","viewRoute","startsWith","remainingPath","slice","length"],"sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"sourcesContent":["import { pathToRegexp } from 'path-to-regexp'\n\nexport const isPathMatchingRoute = ({\n currentRoute,\n exact,\n path: viewPath,\n sensitive,\n strict,\n}: {\n currentRoute: string\n exact?: boolean\n path?: string\n sensitive?: boolean\n strict?: boolean\n}) => {\n // if no path is defined, we cannot match it so return false early\n if (!viewPath) {\n return false\n }\n\n const keys = []\n\n // run the view path through `pathToRegexp` to resolve any dynamic segments\n // i.e. `/admin/custom-view/:id` -> `/admin/custom-view/123`\n const regex = pathToRegexp(viewPath, keys, {\n sensitive,\n strict,\n })\n\n const match = regex.exec(currentRoute)\n const viewRoute = match?.[0] || viewPath\n\n if (exact) {\n return currentRoute === viewRoute\n }\n\n if (!exact) {\n if (!currentRoute.startsWith(viewRoute)) {\n return false\n }\n\n const remainingPath = currentRoute.slice(viewRoute.length)\n\n return remainingPath === '' || remainingPath.startsWith('/')\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ;AAE7B,OAAO,MAAMC,mBAAA,GAAsBA,CAAC;EAClCC,YAAY;EACZC,KAAK;EACLC,IAAA,EAAMC,QAAQ;EACdC,SAAS;EACTC;AAAM,CAOP;EACC;EACA,IAAI,CAACF,QAAA,EAAU;IACb,OAAO;EACT;EAEA,MAAMG,IAAA,GAAO,EAAE;EAEf;EACA;EACA,MAAMC,KAAA,GAAQT,YAAA,CAAaK,QAAA,EAAUG,IAAA,EAAM;IACzCF,SAAA;IACAC;EACF;EAEA,MAAMG,KAAA,GAAQD,KAAA,CAAME,IAAI,CAACT,YAAA;EACzB,MAAMU,SAAA,GAAYF,KAAA,GAAQ,EAAE,IAAIL,QAAA;EAEhC,IAAIF,KAAA,EAAO;IACT,OAAOD,YAAA,KAAiBU,SAAA;EAC1B;EAEA,IAAI,CAACT,KAAA,EAAO;IACV,IAAI,CAACD,YAAA,CAAaW,UAAU,CAACD,SAAA,GAAY;MACvC,OAAO;IACT;IAEA,MAAME,aAAA,GAAgBZ,YAAA,CAAaa,KAAK,CAACH,SAAA,CAAUI,MAAM;IAEzD,OAAOF,aAAA,KAAkB,MAAMA,aAAA,CAAcD,UAAU,CAAC;EAC1D;AACF","ignoreList":[]}
1
+ {"version":3,"file":"isPathMatchingRoute.js","names":["pathToRegexp","stripTrailingSlash","isPathMatchingRoute","currentRoute","exact","path","viewPath","sensitive","strict","normalizedCurrentRoute","keys","regex","match","exec","viewRoute","startsWith","remainingPath","slice","length"],"sources":["../../../src/views/Root/isPathMatchingRoute.ts"],"sourcesContent":["import { pathToRegexp } from 'path-to-regexp'\nimport { stripTrailingSlash } from 'payload/shared'\n\nexport const isPathMatchingRoute = ({\n currentRoute,\n exact,\n path: viewPath,\n sensitive,\n strict,\n}: {\n currentRoute: string\n exact?: boolean\n path?: string\n sensitive?: boolean\n strict?: boolean\n}) => {\n // if no path is defined, we cannot match it so return false early\n if (!viewPath) {\n return false\n }\n\n const normalizedCurrentRoute = strict ? currentRoute : stripTrailingSlash(currentRoute)\n const keys = []\n\n // run the view path through `pathToRegexp` to resolve any dynamic segments\n // i.e. `/admin/custom-view/:id` -> `/admin/custom-view/123`\n const regex = pathToRegexp(viewPath, keys, {\n sensitive,\n strict,\n })\n\n const match = regex.exec(normalizedCurrentRoute)\n const viewRoute = strict ? match?.[0] || viewPath : stripTrailingSlash(match?.[0] || viewPath)\n\n if (exact) {\n return normalizedCurrentRoute === viewRoute\n }\n\n if (!exact) {\n if (!normalizedCurrentRoute.startsWith(viewRoute)) {\n return false\n }\n\n const remainingPath = normalizedCurrentRoute.slice(viewRoute.length)\n\n return remainingPath === '' || remainingPath.startsWith('/')\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ;AAC7B,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,MAAMC,mBAAA,GAAsBA,CAAC;EAClCC,YAAY;EACZC,KAAK;EACLC,IAAA,EAAMC,QAAQ;EACdC,SAAS;EACTC;AAAM,CAOP;EACC;EACA,IAAI,CAACF,QAAA,EAAU;IACb,OAAO;EACT;EAEA,MAAMG,sBAAA,GAAyBD,MAAA,GAASL,YAAA,GAAeF,kBAAA,CAAmBE,YAAA;EAC1E,MAAMO,IAAA,GAAO,EAAE;EAEf;EACA;EACA,MAAMC,KAAA,GAAQX,YAAA,CAAaM,QAAA,EAAUI,IAAA,EAAM;IACzCH,SAAA;IACAC;EACF;EAEA,MAAMI,KAAA,GAAQD,KAAA,CAAME,IAAI,CAACJ,sBAAA;EACzB,MAAMK,SAAA,GAAYN,MAAA,GAASI,KAAA,GAAQ,EAAE,IAAIN,QAAA,GAAWL,kBAAA,CAAmBW,KAAA,GAAQ,EAAE,IAAIN,QAAA;EAErF,IAAIF,KAAA,EAAO;IACT,OAAOK,sBAAA,KAA2BK,SAAA;EACpC;EAEA,IAAI,CAACV,KAAA,EAAO;IACV,IAAI,CAACK,sBAAA,CAAuBM,UAAU,CAACD,SAAA,GAAY;MACjD,OAAO;IACT;IAEA,MAAME,aAAA,GAAgBP,sBAAA,CAAuBQ,KAAK,CAACH,SAAA,CAAUI,MAAM;IAEnE,OAAOF,aAAA,KAAkB,MAAMA,aAAA,CAAcD,UAAU,CAAC;EAC1D;AACF","ignoreList":[]}
@@ -23,6 +23,13 @@ describe('isPathMatchingRoute', () => {
23
23
  path: '/dashboard'
24
24
  })).toBe(true);
25
25
  });
26
+ it('should match a trailing-slash path with a normalized current route', () => {
27
+ expect(isPathMatchingRoute({
28
+ currentRoute: '/dashboard',
29
+ exact: true,
30
+ path: '/dashboard/'
31
+ })).toBe(true);
32
+ });
26
33
  it('should not match when currentRoute differs from the path', () => {
27
34
  expect(isPathMatchingRoute({
28
35
  currentRoute: '/settings',
@@ -1 +1 @@
1
- {"version":3,"file":"isPathMatchingRoute.spec.js","names":["describe","expect","it","isPathMatchingRoute","currentRoute","path","undefined","toBe","exact","sensitive","strict"],"sources":["../../../src/views/Root/isPathMatchingRoute.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\ndescribe('isPathMatchingRoute', () => {\n describe('no path defined', () => {\n it('should return false when path is undefined', () => {\n expect(isPathMatchingRoute({ currentRoute: '/anything', path: undefined })).toBe(false)\n })\n\n it('should return false when path is empty string', () => {\n expect(isPathMatchingRoute({ currentRoute: '/anything', path: '' })).toBe(false)\n })\n })\n\n describe('exact matching', () => {\n it('should match when currentRoute exactly equals the static path', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/dashboard', exact: true, path: '/dashboard' }),\n ).toBe(true)\n })\n\n it('should not match when currentRoute differs from the path', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/settings', exact: true, path: '/dashboard' }),\n ).toBe(false)\n })\n\n it('should not match a sub-path when exact is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/settings',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(false)\n })\n\n it('should match a parameterized path exactly', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123',\n exact: true,\n path: '/custom/:id',\n }),\n ).toBe(true)\n })\n\n it('should not match a parameterized path with extra segments', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123/edit',\n exact: true,\n path: '/custom/:id',\n }),\n ).toBe(false)\n })\n\n it('should match root path exactly', () => {\n expect(isPathMatchingRoute({ currentRoute: '/', exact: true, path: '/' })).toBe(true)\n })\n\n it('should not match root path against other routes when exact', () => {\n expect(isPathMatchingRoute({ currentRoute: '/login', exact: true, path: '/' })).toBe(false)\n })\n })\n\n describe('non-exact (prefix) matching', () => {\n it('should match when currentRoute equals the path', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard', path: '/dashboard' })).toBe(true)\n })\n\n it('should match a sub-path at a segment boundary', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard/settings', path: '/dashboard' })).toBe(\n true,\n )\n })\n\n it('should match deeply nested sub-paths', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/settings/advanced/debug',\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match when route shares a prefix but not at a segment boundary', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard-extra', path: '/dashboard' })).toBe(\n false,\n )\n })\n\n it('should not match a completely different route', () => {\n expect(isPathMatchingRoute({ currentRoute: '/settings', path: '/dashboard' })).toBe(false)\n })\n\n it('should match a parameterized path with a sub-path', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123/edit',\n path: '/custom/:id',\n }),\n ).toBe(false)\n // pathToRegexp is end-anchored by default, so /custom/:id does not match /custom/123/edit.\n // The literal fallback '/custom/:id' also won't startsWith-match.\n // Parameterized views should use exact: true or include all segments in the pattern.\n })\n\n it('should match when :id captures the full segment including non-slash characters', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123extra',\n path: '/custom/:id',\n }),\n ).toBe(true)\n // :id captures everything up to the next / — '123extra' is a valid :id value\n })\n })\n\n describe('root path / without exact — regression for route shadowing bug', () => {\n it('should match root path against itself', () => {\n expect(isPathMatchingRoute({ currentRoute: '/', path: '/' })).toBe(true)\n })\n\n it('should not match root path against /login', () => {\n expect(isPathMatchingRoute({ currentRoute: '/login', path: '/' })).toBe(false)\n })\n\n it('should not match root path against /collections/posts', () => {\n expect(isPathMatchingRoute({ currentRoute: '/collections/posts', path: '/' })).toBe(false)\n })\n\n it('should not match root path against /collections/posts/123', () => {\n expect(isPathMatchingRoute({ currentRoute: '/collections/posts/123', path: '/' })).toBe(false)\n })\n })\n\n describe('sensitive option', () => {\n it('should match case-insensitively by default', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/Dashboard',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match different cases when sensitive is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/Dashboard',\n exact: true,\n path: '/dashboard',\n sensitive: true,\n }),\n ).toBe(false)\n })\n })\n\n describe('strict option', () => {\n it('should match with or without trailing slash by default', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match trailing slash mismatch when strict is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/d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dI,KAAA,EAAO;QACPH,IAAA,EAAM;QACNK,MAAA,EAAQ;MACV,IACAH,IAAI,CAAC;IACT;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"isPathMatchingRoute.spec.js","names":["describe","expect","it","isPathMatchingRoute","currentRoute","path","undefined","toBe","exact","sensitive","strict"],"sources":["../../../src/views/Root/isPathMatchingRoute.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\ndescribe('isPathMatchingRoute', () => {\n describe('no path defined', () => {\n it('should return false when path is undefined', () => {\n expect(isPathMatchingRoute({ currentRoute: '/anything', path: undefined })).toBe(false)\n })\n\n it('should return false when path is empty string', () => {\n expect(isPathMatchingRoute({ currentRoute: '/anything', path: '' })).toBe(false)\n })\n })\n\n describe('exact matching', () => {\n it('should match when currentRoute exactly equals the static path', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/dashboard', exact: true, path: '/dashboard' }),\n ).toBe(true)\n })\n\n it('should match a trailing-slash path with a normalized current route', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/dashboard', exact: true, path: '/dashboard/' }),\n ).toBe(true)\n })\n\n it('should not match when currentRoute differs from the path', () => {\n expect(\n isPathMatchingRoute({ currentRoute: '/settings', exact: true, path: '/dashboard' }),\n ).toBe(false)\n })\n\n it('should not match a sub-path when exact is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/settings',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(false)\n })\n\n it('should match a parameterized path exactly', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123',\n exact: true,\n path: '/custom/:id',\n }),\n ).toBe(true)\n })\n\n it('should not match a parameterized path with extra segments', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123/edit',\n exact: true,\n path: '/custom/:id',\n }),\n ).toBe(false)\n })\n\n it('should match root path exactly', () => {\n expect(isPathMatchingRoute({ currentRoute: '/', exact: true, path: '/' })).toBe(true)\n })\n\n it('should not match root path against other routes when exact', () => {\n expect(isPathMatchingRoute({ currentRoute: '/login', exact: true, path: '/' })).toBe(false)\n })\n })\n\n describe('non-exact (prefix) matching', () => {\n it('should match when currentRoute equals the path', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard', path: '/dashboard' })).toBe(true)\n })\n\n it('should match a sub-path at a segment boundary', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard/settings', path: '/dashboard' })).toBe(\n true,\n )\n })\n\n it('should match deeply nested sub-paths', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/settings/advanced/debug',\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match when route shares a prefix but not at a segment boundary', () => {\n expect(isPathMatchingRoute({ currentRoute: '/dashboard-extra', path: '/dashboard' })).toBe(\n false,\n )\n })\n\n it('should not match a completely different route', () => {\n expect(isPathMatchingRoute({ currentRoute: '/settings', path: '/dashboard' })).toBe(false)\n })\n\n it('should match a parameterized path with a sub-path', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123/edit',\n path: '/custom/:id',\n }),\n ).toBe(false)\n // pathToRegexp is end-anchored by default, so /custom/:id does not match /custom/123/edit.\n // The literal fallback '/custom/:id' also won't startsWith-match.\n // Parameterized views should use exact: true or include all segments in the pattern.\n })\n\n it('should match when :id captures the full segment including non-slash characters', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/custom/123extra',\n path: '/custom/:id',\n }),\n ).toBe(true)\n // :id captures everything up to the next / — '123extra' is a valid :id value\n })\n })\n\n describe('root path / without exact — regression for route shadowing bug', () => {\n it('should match root path against itself', () => {\n expect(isPathMatchingRoute({ currentRoute: '/', path: '/' })).toBe(true)\n })\n\n it('should not match root path against /login', () => {\n expect(isPathMatchingRoute({ currentRoute: '/login', path: '/' })).toBe(false)\n })\n\n it('should not match root path against /collections/posts', () => {\n expect(isPathMatchingRoute({ currentRoute: '/collections/posts', path: '/' })).toBe(false)\n })\n\n it('should not match root path against /collections/posts/123', () => {\n expect(isPathMatchingRoute({ currentRoute: '/collections/posts/123', path: '/' })).toBe(false)\n })\n })\n\n describe('sensitive option', () => {\n it('should match case-insensitively by default', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/Dashboard',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match different cases when sensitive is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/Dashboard',\n exact: true,\n path: '/dashboard',\n sensitive: true,\n }),\n ).toBe(false)\n })\n })\n\n describe('strict option', () => {\n it('should match with or without trailing slash by default', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/',\n exact: true,\n path: '/dashboard',\n }),\n ).toBe(true)\n })\n\n it('should not match trailing slash mismatch when strict is true', () => {\n expect(\n isPathMatchingRoute({\n currentRoute: '/dashboard/',\n exact: true,\n path: '/dashboard',\n strict: true,\n }),\n ).toBe(false)\n })\n })\n})\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,mBAAmB,QAAQ;AAEpCH,QAAA,CAAS,uBAAuB;EAC9BA,QAAA,CAAS,mBAAmB;IAC1BE,EAAA,CAAG,8CAA8C;MAC/CD,MAAA,CAAOE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAaC,IAAA,EAAMC;MAAU,IAAIC,IAAI,CAAC;IACnF;IAEAL,EAAA,CAAG,iDAAiD;MAClDD,MAAA,CAAOE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAaC,IAAA,EAAM;MAAG,IAAIE,IAAI,CAAC;IAC5E;EACF;EAEAP,QAAA,CAAS,kBAAkB;IACzBE,EAAA,CAAG,iEAAiE;MAClED,MAAA,CACEE,mBAAA,CAAoB;QAAEC,YAAA,EAAc;QAAcI,KAAA,EAAO;QAAMH,IAAA,EAAM;MAAa,IAClFE,IAAI,CAAC;IACT;IAEAL,EAAA,CAAG,sEAAsE;MACvED,MAAA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B;QAAEC,YAAA,EAAc;QAA0BC,IAAA,EAAM;MAAI,IAAIE,IAAI,CAAC;IAC1F;EACF;EAEAP,QAAA,CAAS,oBAAoB;IAC3BE,EAAA,CAAG,8CAA8C;MAC/CD,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;MACR,IACAE,IAAI,CAAC;IACT;IAEAL,EAAA,CAAG,2DAA2D;MAC5DD,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;QACNI,SAAA,EAAW;MACb,IACAF,IAAI,CAAC;IACT;EACF;EAEAP,QAAA,CAAS,iBAAiB;IACxBE,EAAA,CAAG,0DAA0D;MAC3DD,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;MACR,IACAE,IAAI,CAAC;IACT;IAEAL,EAAA,CAAG,gEAAgE;MACjED,MAAA,CACEE,mBAAA,CAAoB;QAClBC,YAAA,EAAc;QACdI,KAAA,EAAO;QACPH,IAAA,EAAM;QACNK,MAAA,EAAQ;MACV,IACAH,IAAI,CAAC;IACT;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Version/Restore/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAiBpG,OAAO,cAAc,CAAA;AAErB,OAAO,KAA0C,MAAM,OAAO,CAAA;AAK9D,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,sBAAsB,CAAA;IACzC,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC,KAAK,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAA;IACtD,aAAa,EAAE,MAAM,GAAG,MAAM,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oBAAoB,EAAE,MAAM,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAoHnC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Version/Restore/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAiBpG,OAAO,cAAc,CAAA;AAErB,OAAO,KAA0C,MAAM,OAAO,CAAA;AAK9D,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,sBAAsB,CAAA;IACzC,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC,KAAK,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAA;IACtD,aAAa,EAAE,MAAM,GAAG,MAAM,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oBAAoB,EAAE,MAAM,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAuHnC,CAAA"}
@@ -45,20 +45,23 @@ export const Restore = ({
45
45
  });
46
46
  const canRestoreAsDraft = status !== 'draft' && collectionConfig?.versions?.drafts;
47
47
  const handleRestore = useCallback(async () => {
48
- let fetchURL = formatAdminURL({
49
- apiRoute,
50
- path: ''
51
- });
48
+ let fetchURL;
52
49
  let redirectURL;
53
50
  if (collectionConfig) {
54
- fetchURL = `${fetchURL}/${collectionConfig.slug}/versions/${versionID}?draft=${draft}`;
51
+ fetchURL = formatAdminURL({
52
+ apiRoute,
53
+ path: `/${collectionConfig.slug}/versions/${versionID}?draft=${draft}`
54
+ });
55
55
  redirectURL = formatAdminURL({
56
56
  adminRoute,
57
57
  path: `/collections/${collectionConfig.slug}/${originalDocID}`
58
58
  });
59
59
  }
60
60
  if (globalConfig) {
61
- fetchURL = `${fetchURL}/globals/${globalConfig.slug}/versions/${versionID}?draft=${draft}`;
61
+ fetchURL = formatAdminURL({
62
+ apiRoute,
63
+ path: `/globals/${globalConfig.slug}/versions/${versionID}?draft=${draft}`
64
+ });
62
65
  redirectURL = formatAdminURL({
63
66
  adminRoute,
64
67
  path: `/globals/${globalConfig.slug}`
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getTranslation","Button","ConfirmationModal","PopupList","toast","useConfig","useModal","useRouteTransition","useTranslation","requests","useRouter","formatAdminURL","React","Fragment","useCallback","useState","baseClass","modalSlug","Restore","className","collectionConfig","globalConfig","label","originalDocID","status","versionDateFormatted","versionID","config","routes","admin","adminRoute","api","apiRoute","toggleModal","router","i18n","t","draft","setDraft","startRouteTransition","restoreMessage","versionDate","canRestoreAsDraft","versions","drafts","handleRestore","fetchURL","path","redirectURL","slug","res","post","headers","language","json","success","message","push","error","_jsxs","_jsx","filter","Boolean","join","buttonStyle","onClick","size","SubMenuPopupContent","ButtonGroup","body","confirmingLabel","heading","onConfirm"],"sources":["../../../../src/views/Version/Restore/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientCollectionConfig, ClientGlobalConfig, SanitizedCollectionConfig } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n ConfirmationModal,\n PopupList,\n toast,\n useConfig,\n useModal,\n useRouteTransition,\n useTranslation,\n} from '@payloadcms/ui'\nimport { requests } from '@payloadcms/ui/shared'\nimport { useRouter } from 'next/navigation.js'\nimport { formatAdminURL } from 'payload/shared'\n\nimport './index.scss'\n\nimport React, { Fragment, useCallback, useState } from 'react'\n\nconst baseClass = 'restore-version'\nconst modalSlug = 'restore-version'\n\ntype Props = {\n className?: string\n collectionConfig?: ClientCollectionConfig\n globalConfig?: ClientGlobalConfig\n label: SanitizedCollectionConfig['labels']['singular']\n originalDocID: number | string\n status?: string\n versionDateFormatted: string\n versionID: string\n}\n\nexport const Restore: React.FC<Props> = ({\n className,\n collectionConfig,\n globalConfig,\n label,\n originalDocID,\n status,\n versionDateFormatted,\n versionID,\n}) => {\n const {\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n },\n } = useConfig()\n\n const { toggleModal } = useModal()\n const router = useRouter()\n const { i18n, t } = useTranslation()\n const [draft, setDraft] = useState(false)\n const { startRouteTransition } = useRouteTransition()\n\n const restoreMessage = t(\n globalConfig ? 'version:aboutToRestoreGlobal' : 'version:aboutToRestore',\n {\n label: getTranslation(label, i18n),\n versionDate: versionDateFormatted,\n },\n )\n\n const canRestoreAsDraft = status !== 'draft' && collectionConfig?.versions?.drafts\n\n const handleRestore = useCallback(async () => {\n let fetchURL = formatAdminURL({\n apiRoute,\n path: '',\n })\n let redirectURL: string\n\n if (collectionConfig) {\n fetchURL = `${fetchURL}/${collectionConfig.slug}/versions/${versionID}?draft=${draft}`\n redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig.slug}/${originalDocID}`,\n })\n }\n\n if (globalConfig) {\n fetchURL = `${fetchURL}/globals/${globalConfig.slug}/versions/${versionID}?draft=${draft}`\n redirectURL = formatAdminURL({\n adminRoute,\n path: `/globals/${globalConfig.slug}`,\n })\n }\n\n const res = await requests.post(fetchURL, {\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n\n if (res.status === 200) {\n const json = await res.json()\n toast.success(json.message)\n return startRouteTransition(() => router.push(redirectURL))\n } else {\n toast.error(t('version:problemRestoringVersion'))\n }\n }, [\n apiRoute,\n collectionConfig,\n globalConfig,\n i18n.language,\n versionID,\n draft,\n adminRoute,\n originalDocID,\n startRouteTransition,\n router,\n t,\n ])\n\n return (\n <Fragment>\n <div className={[baseClass, className].filter(Boolean).join(' ')}>\n <Button\n buttonStyle=\"primary\"\n className={[canRestoreAsDraft && `${baseClass}__restore-as-draft-button`]\n .filter(Boolean)\n .join(' ')}\n onClick={() => toggleModal(modalSlug)}\n size=\"xsmall\"\n SubMenuPopupContent={\n canRestoreAsDraft\n ? () => (\n <PopupList.ButtonGroup>\n <PopupList.Button onClick={() => [setDraft(true), toggleModal(modalSlug)]}>\n {t('version:restoreAsDraft')}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )\n : null\n }\n >\n {t('version:restoreThisVersion')}\n </Button>\n </div>\n <ConfirmationModal\n body={restoreMessage}\n confirmingLabel={t('version:restoring')}\n heading={t('version:confirmVersionRestoration')}\n modalSlug={modalSlug}\n onConfirm={handleRestore}\n />\n </Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACRC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,QAAQ,QAAQ;AACzB,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAI/B,OAAOC,KAAA,IAASC,QAAQ,EAAEC,WAAW,EAAEC,QAAQ,QAAQ;AAEvD,MAAMC,SAAA,GAAY;AAClB,MAAMC,SAAA,GAAY;AAalB,OAAO,MAAMC,OAAA,GAA2BA,CAAC;EACvCC,SAAS;EACTC,gBAAgB;EAChBC,YAAY;EACZC,KAAK;EACLC,aAAa;EACbC,MAAM;EACNC,oBAAoB;EACpBC;AAAS,CACV;EACC,MAAM;IACJC,MAAA,EAAQ;MACNC,MAAA,EAAQ;QAAEC,KAAA,EAAOC,UAAU;QAAEC,GAAA,EAAKC;MAAQ;IAAE;EAC7C,CACF,GAAG3B,SAAA;EAEJ,MAAM;IAAE4B;EAAW,CAAE,GAAG3B,QAAA;EACxB,MAAM4B,MAAA,GAASxB,SAAA;EACf,MAAM;IAAEyB,IAAI;IAAEC;EAAC,CAAE,GAAG5B,cAAA;EACpB,MAAM,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CAACD,IAAA,CAAKE,OAAO;MAC1B,OAAOjB,oBAAA,CAAqB,MAAML,MAAA,CAAOuB,IAAI,CAACT,WAAA;IAChD,OAAO;MACL5C,KAAA,CAAMsD,KAAK,CAACtB,CAAA,CAAE;IAChB;EACF,GAAG,CACDJ,QAAA,EACAZ,gBAAA,EACAC,YAAA,EACAc,IAAA,CAAKkB,QAAQ,EACb3B,SAAA,EACAW,KAAA,EACAP,UAAA,EACAP,aAAA,EACAgB,oBAAA,EACAL,MAAA,EACAE,CAAA,CACD;EAED,oBACEuB,KAAA,CAAC9C,QAAA;4BACC+C,IAAA,CAAC;MAAIzC,SAAA,EAAW,CAACH,SAAA,EAAWG,SAAA,CAAU,CAAC0C,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;gBAC1D,aAAAH,IAAA,CAAC3D,MAAA;QACC+D,WAAA,EAAY;QACZ7C,SAAA,EAAW,CAACuB,iBAAA,IAAqB,GAAG1B,SAAA,2BAAoC,CAAC,CACtE6C,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;QACRE,OAAA,EAASA,CAAA,KAAMhC,WAAA,CAAYhB,SAAA;QAC3BiD,IAAA,EAAK;QACLC,mBAAA,EACEzB,iBAAA,GACI,mBACEkB,IAAA,CAACzD,SAAA,CAAUiE,WAAW;oBACpB,aAAAR,IAAA,CAACzD,SAAA,CAAUF,MAAM;YAACgE,OAAA,EAASA,CAAA,KAAM,CAAC3B,QAAA,CAAS,OAAOL,WAAA,CAAYhB,SAAA,EAAW;sBACtEmB,CAAA,CAAE;;aAIT;kBAGLA,CAAA,CAAE;;qBAGPwB,IAAA,CAAC1D,iBAAA;MACCmE,IAAA,EAAM7B,cAAA;MACN8B,eAAA,EAAiBlC,CAAA,CAAE;MACnBmC,OAAA,EAASnC,CAAA,CAAE;MACXnB,SAAA,EAAWA,SAAA;MACXuD,SAAA,EAAW3B;;;AAInB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["getTranslation","Button","ConfirmationModal","PopupList","toast","useConfig","useModal","useRouteTransition","useTranslation","requests","useRouter","formatAdminURL","React","Fragment","useCallback","useState","baseClass","modalSlug","Restore","className","collectionConfig","globalConfig","label","originalDocID","status","versionDateFormatted","versionID","config","routes","admin","adminRoute","api","apiRoute","toggleModal","router","i18n","t","draft","setDraft","startRouteTransition","restoreMessage","versionDate","canRestoreAsDraft","versions","drafts","handleRestore","fetchURL","redirectURL","path","slug","res","post","headers","language","json","success","message","push","error","_jsxs","_jsx","filter","Boolean","join","buttonStyle","onClick","size","SubMenuPopupContent","ButtonGroup","body","confirmingLabel","heading","onConfirm"],"sources":["../../../../src/views/Version/Restore/index.tsx"],"sourcesContent":["'use client'\n\nimport type { ClientCollectionConfig, ClientGlobalConfig, SanitizedCollectionConfig } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n ConfirmationModal,\n PopupList,\n toast,\n useConfig,\n useModal,\n useRouteTransition,\n useTranslation,\n} from '@payloadcms/ui'\nimport { requests } from '@payloadcms/ui/shared'\nimport { useRouter } from 'next/navigation.js'\nimport { formatAdminURL } from 'payload/shared'\n\nimport './index.scss'\n\nimport React, { Fragment, useCallback, useState } from 'react'\n\nconst baseClass = 'restore-version'\nconst modalSlug = 'restore-version'\n\ntype Props = {\n className?: string\n collectionConfig?: ClientCollectionConfig\n globalConfig?: ClientGlobalConfig\n label: SanitizedCollectionConfig['labels']['singular']\n originalDocID: number | string\n status?: string\n versionDateFormatted: string\n versionID: string\n}\n\nexport const Restore: React.FC<Props> = ({\n className,\n collectionConfig,\n globalConfig,\n label,\n originalDocID,\n status,\n versionDateFormatted,\n versionID,\n}) => {\n const {\n config: {\n routes: { admin: adminRoute, api: apiRoute },\n },\n } = useConfig()\n\n const { toggleModal } = useModal()\n const router = useRouter()\n const { i18n, t } = useTranslation()\n const [draft, setDraft] = useState(false)\n const { startRouteTransition } = useRouteTransition()\n\n const restoreMessage = t(\n globalConfig ? 'version:aboutToRestoreGlobal' : 'version:aboutToRestore',\n {\n label: getTranslation(label, i18n),\n versionDate: versionDateFormatted,\n },\n )\n\n const canRestoreAsDraft = status !== 'draft' && collectionConfig?.versions?.drafts\n\n const handleRestore = useCallback(async () => {\n let fetchURL: string\n let redirectURL: string\n\n if (collectionConfig) {\n fetchURL = formatAdminURL({\n apiRoute,\n path: `/${collectionConfig.slug}/versions/${versionID}?draft=${draft}`,\n })\n redirectURL = formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig.slug}/${originalDocID}`,\n })\n }\n\n if (globalConfig) {\n fetchURL = formatAdminURL({\n apiRoute,\n path: `/globals/${globalConfig.slug}/versions/${versionID}?draft=${draft}`,\n })\n redirectURL = formatAdminURL({\n adminRoute,\n path: `/globals/${globalConfig.slug}`,\n })\n }\n\n const res = await requests.post(fetchURL, {\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n\n if (res.status === 200) {\n const json = await res.json()\n toast.success(json.message)\n return startRouteTransition(() => router.push(redirectURL))\n } else {\n toast.error(t('version:problemRestoringVersion'))\n }\n }, [\n apiRoute,\n collectionConfig,\n globalConfig,\n i18n.language,\n versionID,\n draft,\n adminRoute,\n originalDocID,\n startRouteTransition,\n router,\n t,\n ])\n\n return (\n <Fragment>\n <div className={[baseClass, className].filter(Boolean).join(' ')}>\n <Button\n buttonStyle=\"primary\"\n className={[canRestoreAsDraft && `${baseClass}__restore-as-draft-button`]\n .filter(Boolean)\n .join(' ')}\n onClick={() => toggleModal(modalSlug)}\n size=\"xsmall\"\n SubMenuPopupContent={\n canRestoreAsDraft\n ? () => (\n <PopupList.ButtonGroup>\n <PopupList.Button onClick={() => [setDraft(true), toggleModal(modalSlug)]}>\n {t('version:restoreAsDraft')}\n </PopupList.Button>\n </PopupList.ButtonGroup>\n )\n : null\n }\n >\n {t('version:restoreThisVersion')}\n </Button>\n </div>\n <ConfirmationModal\n body={restoreMessage}\n confirmingLabel={t('version:restoring')}\n heading={t('version:confirmVersionRestoration')}\n modalSlug={modalSlug}\n onConfirm={handleRestore}\n />\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AAA,EAAWG,SAAA,CAAU,CAAC0C,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;gBAC1D,aAAAH,IAAA,CAAC3D,MAAA;QACC+D,WAAA,EAAY;QACZ7C,SAAA,EAAW,CAACuB,iBAAA,IAAqB,GAAG1B,SAAA,2BAAoC,CAAC,CACtE6C,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;QACRE,OAAA,EAASA,CAAA,KAAMhC,WAAA,CAAYhB,SAAA;QAC3BiD,IAAA,EAAK;QACLC,mBAAA,EACEzB,iBAAA,GACI,mBACEkB,IAAA,CAACzD,SAAA,CAAUiE,WAAW;oBACpB,aAAAR,IAAA,CAACzD,SAAA,CAAUF,MAAM;YAACgE,OAAA,EAASA,CAAA,KAAM,CAAC3B,QAAA,CAAS,OAAOL,WAAA,CAAYhB,SAAA,EAAW;sBACtEmB,CAAA,CAAE;;aAIT;kBAGLA,CAAA,CAAE;;qBAGPwB,IAAA,CAAC1D,iBAAA;MACCmE,IAAA,EAAM7B,cAAA;MACN8B,eAAA,EAAiBlC,CAAA,CAAE;MACnBmC,OAAA,EAASnC,CAAA,CAAE;MACXnB,SAAA,EAAWA,SAAA;MACXuD,SAAA,EAAW3B;;;AAInB","ignoreList":[]}
@@ -77,10 +77,6 @@ export const withPayload = (nextConfig = {}, options = {}) => {
77
77
  ...(nextConfig.outputFileTracingExcludes || {}),
78
78
  '**/*': [...(nextConfig.outputFileTracingExcludes?.['**/*'] || []), 'drizzle-kit', 'drizzle-kit/api']
79
79
  },
80
- outputFileTracingIncludes: {
81
- ...(nextConfig.outputFileTracingIncludes || {}),
82
- '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client']
83
- },
84
80
  turbopack: {
85
81
  ...(nextConfig.turbopack || {})
86
82
  },
@@ -194,6 +190,9 @@ export const withPayload = (nextConfig = {}, options = {}) => {
194
190
  process.env.NEXT_BASE_PATH = nextConfig.basePath;
195
191
  baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath;
196
192
  }
193
+ const trailingSlash = nextConfig.trailingSlash === true ? 'true' : 'false';
194
+ process.env.NEXT_TRAILING_SLASH = trailingSlash;
195
+ baseConfig.env.NEXT_TRAILING_SLASH = trailingSlash;
197
196
  if (!supportsTurbopackBuild) {
198
197
  return withPayloadLegacy(baseConfig);
199
198
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"withPayload.js","names":["getNextjsVersion","supportsServerFastRefreshConfig","supportsTurbopackExternalizeTransitiveDependencies","withPayloadLegacy","poweredByHeader","key","value","withPayload","nextConfig","options","nextjsVersion","supportsTurbopackBuild","hasServerFastRefreshConfigOption","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","cacheComponents","PAYLOAD_CACHE_COMPONENTS_ENABLED","major","consoleWarn","sassWarningTexts","args","some","text","includes","baseConfig","turbopackServerFastRefresh","sassOptions","silenceDeprecations","outputFileTracingExcludes","outputFileTracingIncludes","turbopack","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","resolve","alias","fallback","aws4","basePath","NEXT_BASE_PATH"],"sources":["../../src/withPayload/withPayload.js"],"sourcesContent":["/**\n * These files must remain as plain JavaScript (.js) rather than TypeScript (.ts) because they are\n * imported directly in next.config.mjs files. Since next.config files run before the build process,\n * TypeScript compilation is not available. This ensures compatibility with all templates and\n * user projects regardless of their TypeScript setup.\n */\nimport {\n getNextjsVersion,\n supportsServerFastRefreshConfig,\n supportsTurbopackExternalizeTransitiveDependencies,\n} from './withPayload.utils.js'\nimport { withPayloadLegacy } from './withPayloadLegacy.js'\n\nconst poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n}\n\n/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const nextjsVersion = getNextjsVersion()\n\n const supportsTurbopackBuild = supportsTurbopackExternalizeTransitiveDependencies(nextjsVersion)\n const hasServerFastRefreshConfigOption = supportsServerFastRefreshConfig(nextjsVersion)\n\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload: detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n if (nextConfig.cacheComponents) {\n env.PAYLOAD_CACHE_COMPONENTS_ENABLED = 'true'\n }\n\n if (nextjsVersion?.major === 16 && !hasServerFastRefreshConfigOption) {\n console.warn(\n 'Payload: You are using an unsupported Next.js 16 version. You can find the supported Next.js versions here: https://payloadcms.com/docs/getting-started/installation',\n )\n }\n\n const consoleWarn = console.warn\n\n const sassWarningTexts = [\n // This warning is a lie - without silencing import deprecation warnings, sass will spam the console with deprecation warnings\n 'Future import deprecation is not yet active, so silencing it is unnecessary',\n // Sometimes happens despite silenceDeprecations\n 'The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0',\n ]\n console.warn = (...args) => {\n if (\n (typeof args[1] === 'string' && sassWarningTexts.some((text) => args[1].includes(text))) ||\n (typeof args[0] === 'string' && sassWarningTexts.some((text) => args[0].includes(text)))\n ) {\n return\n }\n\n consoleWarn(...args)\n }\n\n /** @type {import('next').NextConfig} */\n const baseConfig = {\n ...nextConfig,\n env,\n experimental: {\n ...(nextConfig.experimental || {}),\n // Server fast refresh breaks HMR\n ...(hasServerFastRefreshConfigOption ? { turbopackServerFastRefresh: false } : {}),\n },\n sassOptions: {\n ...(nextConfig.sassOptions || {}),\n /**\n * This prevents scss warning spam during pnpm dev that looks like this:\n * ⚠ ./test/admin/components/views/CustomMinimal/index.scss\n * Issue while running loader\n * SassWarning: Deprecation Warning on line 8, column 8 of file:///Users/alessio/Documents/GitHub/ payload/packages/ui/src/scss/styles.scss:8:8:\n * Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.\n *\n * More info and automated migrator: https://sass-lang.com/d/import\n *\n * 8 | @import 'queries';\n *\n *\n * packages/ui/src/scss/styles.scss 9:9 @import\n * test/admin/components/views/CustomMinimal/index.scss 1:9 root stylesheet\n *\n * @todo: update all outdated scss imports to use @use instead of @import. Then, we can remove this.\n */\n silenceDeprecations: [...(nextConfig.sassOptions?.silenceDeprecations || []), 'import'],\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev for two reasons:\n *\n * 1. Performance: Fewer files to compile means faster compilation speeds.\n * 2. Turbopack support: Webpack's externals are not supported by Turbopack.\n *\n * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to\n * externalized packages that are not resolvable from the project root. So including a package like\n * \"drizzle-kit\" in here would do nothing - Next.js will ignore the rule and still bundle the package -\n * because it detects that the package is not resolvable from the project root (= not directly installed\n * by the user in their own package.json).\n *\n * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly\n * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).\n *\n *\n *\n * We should only do this during development, not build, because externalizing these packages can hurt\n * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the\n * same package.\n *\n * Example:\n * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)\n * - payload (not in bundle, external) -> installs qs-esm (external because of importer)\n * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.\n *\n * During development, these bundle size difference do not matter much, and development speed /\n * turbopack support are more important.\n */\n [\n 'payload',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/drizzle',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/payload-cloud',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n // see: https://github.com/vercel/next.js/discussions/76991\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\n * See the explanation in the serverExternalPackages section above.\n * We need to force Webpack to emit require() calls for these packages, even though they are not\n * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.\n *\n * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the\n * entry point packages, as explained in the serverExternalPackages section above.\n */\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n ],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n }\n },\n }\n\n if (nextConfig.basePath) {\n process.env.NEXT_BASE_PATH = nextConfig.basePath\n baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n if (!supportsTurbopackBuild) {\n return withPayloadLegacy(baseConfig)\n } else {\n return {\n ...baseConfig,\n serverExternalPackages: [\n ...(baseConfig.serverExternalPackages || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n // Prevents turbopack build errors by the thread-stream package which is installed by pino\n 'pino',\n ],\n }\n }\n}\n\nexport default withPayload\n"],"mappings":"AAAA;;;;;GAMA,SACEA,gBAAgB,EAChBC,+BAA+B,EAC/BC,kDAAkD,QAC7C;AACP,SAASC,iBAAiB,QAAQ;AAElC,MAAMC,eAAA,GAAkB;EACtBC,GAAA,EAAK;EACLC,KAAA,EAAO;AACT;AAEA;;;;;AAKA,OAAO,MAAMC,WAAA,GAAcA,CAACC,UAAA,GAAa,CAAC,CAAC,EAAEC,OAAA,GAAU,CAAC,CAAC;EACvD,MAAMC,aAAA,GAAgBV,gBAAA;EAEtB,MAAMW,sBAAA,GAAyBT,kDAAA,CAAmDQ,aAAA;EAClF,MAAME,gCAAA,GAAmCX,+BAAA,CAAgCS,aAAA;EAEzE,MAAMG,GAAA,GAAML,UAAA,CAAWK,GAAG,IAAI,CAAC;EAE/B,IAAIL,UAAA,CAAWM,YAAY,EAAEC,UAAA,EAAYC,OAAA,EAAS;IAChDC,OAAA,CAAQC,IAAI,CACV;IAEFL,GAAA,CAAIM,uCAAuC,GAAG;EAChD;EAEA,IAAI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AA;MAEN,OAAO;QACL,GAAGE,qBAAqB;QACxBC,SAAA,EAAW,C,IACLD,qBAAA,EAAuBC,SAAA,IAAa,EAAE;QAC1C;;;;;;;;QAQA,eACA,mBACA,SACA,UACA,yBACA,4BACD;QACDC,OAAA,EAAS,C,IACHF,qBAAA,EAAuBE,OAAA,IAAW,EAAE;QACxC;QACA,IAAIH,cAAA,CAAeF,OAAO,CAACM,YAAY,CAAC;UACtCC,cAAA,EAAgB;QAClB,GACD;QACDC,OAAA,EAAS;UACP,IAAIL,qBAAA,EAAuBK,OAAA,IAAW,CAAC,CAAC;UACxCC,KAAA,EAAO;YACL,IAAIN,qBAAA,EAAuBK,OAAA,EAASC,KAAA,IAAS,CAAC,CAAC;UACjD;UACAC,QAAA,EAAU;YACR,IAAIP,qBAAA,EAAuBK,OAAA,EAASE,QAAA,IAAY,CAAC,CAAC;YAClD;;;;;;;;;;;;;;;;;;;YAmBAC,IAAA,EAAM;UACR;QACF;MACF;IACF;EACF;EAEA,IAAI9C,UAAA,CAAW+C,QAAQ,EAAE;IACvBf,OAAA,CAAQ3B,GAAG,CAAC2C,cAAc,GAAGhD,UAAA,CAAW+C,QAAQ;IAChD1B,UAAA,CAAWhB,GAAG,CAAC2C,cAAc,GAAGhD,UAAA,CAAW+C,QAAQ;EACrD;EAEA,IAAI,CAAC5C,sBAAA,EAAwB;IAC3B,OAAOR,iBAAA,CAAkB0B,UAAA;EAC3B,OAAO;IACL,OAAO;MACL,GAAGA,UAAU;MACbU,sBAAA,EAAwB,C,IAClBV,UAAA,CAAWU,sBAAsB,IAAI,EAAE,GAC3C,eACA,mBACA,SACA,UACA,yBACA;MACA;MACA;IAEJ;EACF;AACF;AAEA,eAAehC,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"withPayload.js","names":["getNextjsVersion","supportsServerFastRefreshConfig","supportsTurbopackExternalizeTransitiveDependencies","withPayloadLegacy","poweredByHeader","key","value","withPayload","nextConfig","options","nextjsVersion","supportsTurbopackBuild","hasServerFastRefreshConfigOption","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","cacheComponents","PAYLOAD_CACHE_COMPONENTS_ENABLED","major","consoleWarn","sassWarningTexts","args","some","text","includes","baseConfig","turbopackServerFastRefresh","sassOptions","silenceDeprecations","outputFileTracingExcludes","turbopack","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","resolve","alias","fallback","aws4","basePath","NEXT_BASE_PATH","trailingSlash","NEXT_TRAILING_SLASH"],"sources":["../../src/withPayload/withPayload.js"],"sourcesContent":["/**\n * These files must remain as plain JavaScript (.js) rather than TypeScript (.ts) because they are\n * imported directly in next.config.mjs files. Since next.config files run before the build process,\n * TypeScript compilation is not available. This ensures compatibility with all templates and\n * user projects regardless of their TypeScript setup.\n */\nimport {\n getNextjsVersion,\n supportsServerFastRefreshConfig,\n supportsTurbopackExternalizeTransitiveDependencies,\n} from './withPayload.utils.js'\nimport { withPayloadLegacy } from './withPayloadLegacy.js'\n\nconst poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n}\n\n/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const nextjsVersion = getNextjsVersion()\n\n const supportsTurbopackBuild = supportsTurbopackExternalizeTransitiveDependencies(nextjsVersion)\n const hasServerFastRefreshConfigOption = supportsServerFastRefreshConfig(nextjsVersion)\n\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload: detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n if (nextConfig.cacheComponents) {\n env.PAYLOAD_CACHE_COMPONENTS_ENABLED = 'true'\n }\n\n if (nextjsVersion?.major === 16 && !hasServerFastRefreshConfigOption) {\n console.warn(\n 'Payload: You are using an unsupported Next.js 16 version. You can find the supported Next.js versions here: https://payloadcms.com/docs/getting-started/installation',\n )\n }\n\n const consoleWarn = console.warn\n\n const sassWarningTexts = [\n // This warning is a lie - without silencing import deprecation warnings, sass will spam the console with deprecation warnings\n 'Future import deprecation is not yet active, so silencing it is unnecessary',\n // Sometimes happens despite silenceDeprecations\n 'The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0',\n ]\n console.warn = (...args) => {\n if (\n (typeof args[1] === 'string' && sassWarningTexts.some((text) => args[1].includes(text))) ||\n (typeof args[0] === 'string' && sassWarningTexts.some((text) => args[0].includes(text)))\n ) {\n return\n }\n\n consoleWarn(...args)\n }\n\n /** @type {import('next').NextConfig} */\n const baseConfig = {\n ...nextConfig,\n env,\n experimental: {\n ...(nextConfig.experimental || {}),\n // Server fast refresh breaks HMR\n ...(hasServerFastRefreshConfigOption ? { turbopackServerFastRefresh: false } : {}),\n },\n sassOptions: {\n ...(nextConfig.sassOptions || {}),\n /**\n * This prevents scss warning spam during pnpm dev that looks like this:\n * ⚠ ./test/admin/components/views/CustomMinimal/index.scss\n * Issue while running loader\n * SassWarning: Deprecation Warning on line 8, column 8 of file:///Users/alessio/Documents/GitHub/ payload/packages/ui/src/scss/styles.scss:8:8:\n * Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.\n *\n * More info and automated migrator: https://sass-lang.com/d/import\n *\n * 8 | @import 'queries';\n *\n *\n * packages/ui/src/scss/styles.scss 9:9 @import\n * test/admin/components/views/CustomMinimal/index.scss 1:9 root stylesheet\n *\n * @todo: update all outdated scss imports to use @use instead of @import. Then, we can remove this.\n */\n silenceDeprecations: [...(nextConfig.sassOptions?.silenceDeprecations || []), 'import'],\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig.serverExternalPackages || []),\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev for two reasons:\n *\n * 1. Performance: Fewer files to compile means faster compilation speeds.\n * 2. Turbopack support: Webpack's externals are not supported by Turbopack.\n *\n * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to\n * externalized packages that are not resolvable from the project root. So including a package like\n * \"drizzle-kit\" in here would do nothing - Next.js will ignore the rule and still bundle the package -\n * because it detects that the package is not resolvable from the project root (= not directly installed\n * by the user in their own package.json).\n *\n * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly\n * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).\n *\n *\n *\n * We should only do this during development, not build, because externalizing these packages can hurt\n * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the\n * same package.\n *\n * Example:\n * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)\n * - payload (not in bundle, external) -> installs qs-esm (external because of importer)\n * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.\n *\n * During development, these bundle size difference do not matter much, and development speed /\n * turbopack support are more important.\n */\n [\n 'payload',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/drizzle',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/payload-cloud',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n // see: https://github.com/vercel/next.js/discussions/76991\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\n * See the explanation in the serverExternalPackages section above.\n * We need to force Webpack to emit require() calls for these packages, even though they are not\n * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.\n *\n * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the\n * entry point packages, as explained in the serverExternalPackages section above.\n */\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n ],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n }\n },\n }\n\n if (nextConfig.basePath) {\n process.env.NEXT_BASE_PATH = nextConfig.basePath\n baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n const trailingSlash = nextConfig.trailingSlash === true ? 'true' : 'false'\n process.env.NEXT_TRAILING_SLASH = trailingSlash\n baseConfig.env.NEXT_TRAILING_SLASH = trailingSlash\n\n if (!supportsTurbopackBuild) {\n return withPayloadLegacy(baseConfig)\n } else {\n return {\n ...baseConfig,\n serverExternalPackages: [\n ...(baseConfig.serverExternalPackages || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n // Prevents turbopack build errors by the thread-stream package which is installed by pino\n 'pino',\n ],\n }\n }\n}\n\nexport default withPayload\n"],"mappings":"AAAA;;;;;GAMA,SACEA,gBAAgB,EAChBC,+BAA+B,EAC/BC,kDAAkD,QAC7C;AACP,SAASC,iBAAiB,QAAQ;AAElC,MAAMC,eAAA,GAAkB;EACtBC,GAAA,EAAK;EACLC,KAAA,EAAO;AACT;AAEA;;;;;AAKA,OAAO,MAAMC,WAAA,GAAcA,CAACC,UAAA,GAAa,CAAC,CAAC,EAAEC,OAAA,GAAU,CAAC,CAAC;EACvD,MAAMC,aAAA,GAAgBV,gBAAA;EAEtB,MAAMW,sBAAA,GAAyBT,kDAAA,CAAmDQ,aAAA;EAClF,MAAME,gCAAA,GAAmCX,+BAAA,CAAgCS,aAAA;EAEzE,MAAMG,GAAA,GAAML,UAAA,CAAWK,GAAG,IAAI,CAAC;EAE/B,IAAIL,UAAA,CAAWM,YAAY,EAAEC,UAAA,EAAYC,OAAA,EAAS;IAChDC,OAAA,CAAQC,IAAI,CACV;IAEFL,GAAA,CAAIM,uCAAuC,GAAG;EAChD;EAEA,IAAIX,UAAA,CAAWY,eAAe,EAAE;IAC9BP,GAAA,CAAIQ,gCAAgC,GAAG;EACzC;EAEA,IAAIX,aAAA,EAAeY,KAAA,KAAU,MAAM,CAACV,gCAAA,EAAkC;IACpEK,OAAA,CAAQC,IAAI,CACV;EAEJ;EAEA,MAAMK,WAAA,GAAcN,OAAA,CAAQC,IAAI;EAEhC,MAAMM,gBAAA,GAAmB;EACvB;EACA;EACA;EACA,yEACD;EACDP,OAAA,CAAQC,IAAI,GAAG,CAAC,GAAGO,IAAA;IACjB,IACE,OAAQA,IAAI,CAAC,E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AA,IAAY,CAAC,CAAC;YAClD;;;;;;;;;;;;;;;;;;;YAmBAC,IAAA,EAAM;UACR;QACF;MACF;IACF;EACF;EAEA,IAAI7C,UAAA,CAAW8C,QAAQ,EAAE;IACvBf,OAAA,CAAQ1B,GAAG,CAAC0C,cAAc,GAAG/C,UAAA,CAAW8C,QAAQ;IAChDzB,UAAA,CAAWhB,GAAG,CAAC0C,cAAc,GAAG/C,UAAA,CAAW8C,QAAQ;EACrD;EAEA,MAAME,aAAA,GAAgBhD,UAAA,CAAWgD,aAAa,KAAK,OAAO,SAAS;EACnEjB,OAAA,CAAQ1B,GAAG,CAAC4C,mBAAmB,GAAGD,aAAA;EAClC3B,UAAA,CAAWhB,GAAG,CAAC4C,mBAAmB,GAAGD,aAAA;EAErC,IAAI,CAAC7C,sBAAA,EAAwB;IAC3B,OAAOR,iBAAA,CAAkB0B,UAAA;EAC3B,OAAO;IACL,OAAO;MACL,GAAGA,UAAU;MACbS,sBAAA,EAAwB,C,IAClBT,UAAA,CAAWS,sBAAsB,IAAI,EAAE,GAC3C,eACA,mBACA,SACA,UACA,yBACA;MACA;MACA;IAEJ;EACF;AACF;AAEA,eAAe/B,WAAA","ignoreList":[]}
@@ -36,5 +36,25 @@ describe('withPayload', () => {
36
36
  }
37
37
  }
38
38
  });
39
+ it('should mirror nextConfig.trailingSlash in process.env.NEXT_TRAILING_SLASH', () => {
40
+ const originalTrailingSlash = process.env.NEXT_TRAILING_SLASH;
41
+ try {
42
+ process.env.NEXT_TRAILING_SLASH = 'true';
43
+ withPayload({
44
+ trailingSlash: false
45
+ });
46
+ expect(process.env.NEXT_TRAILING_SLASH).toBe('false');
47
+ withPayload({
48
+ trailingSlash: true
49
+ });
50
+ expect(process.env.NEXT_TRAILING_SLASH).toBe('true');
51
+ } finally {
52
+ if (originalTrailingSlash === undefined) {
53
+ delete process.env.NEXT_TRAILING_SLASH;
54
+ } else {
55
+ process.env.NEXT_TRAILING_SLASH = originalTrailingSlash;
56
+ }
57
+ }
58
+ });
39
59
  });
40
60
  //# sourceMappingURL=withPayload.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withPayload.spec.js","names":["describe","expect","it","withPayload","originalBasePath","process","env","NEXT_BASE_PATH","mockNextConfig","basePath","toBe","undefined"],"sources":["../../src/withPayload/withPayload.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { withPayload } from './withPayload.js'\n\ndescribe('withPayload', () => {\n it('should set process.env.NEXT_BASE_PATH when nextConfig.basePath is provided', () => {\n const originalBasePath = process.env.NEXT_BASE_PATH\n delete process.env.NEXT_BASE_PATH\n\n try {\n const mockNextConfig = {\n basePath: '/test/basepath',\n }\n\n withPayload(mockNextConfig)\n\n // Verify it set the env var so formatAdminURL can read it\n expect(process.env.NEXT_BASE_PATH).toBe('/test/basepath')\n } finally {\n // Restore original value\n if (originalBasePath === undefined) {\n delete process.env.NEXT_BASE_PATH\n } else {\n process.env.NEXT_BASE_PATH = originalBasePath\n }\n }\n })\n\n it('should not modify process.env.NEXT_BASE_PATH when basePath is not provided', () => {\n const originalBasePath = process.env.NEXT_BASE_PATH\n\n try {\n const mockNextConfig = {}\n\n withPayload(mockNextConfig)\n\n // Verify it didn't set the env var\n expect(process.env.NEXT_BASE_PATH).toBe(originalBasePath)\n } finally {\n // Restore original value\n if (originalBasePath === undefined) {\n delete process.env.NEXT_BASE_PATH\n } else {\n process.env.NEXT_BASE_PATH = originalBasePath\n }\n }\n })\n})\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,WAAW,QAAQ;AAE5BH,QAAA,CAAS,eAAe;EACtBE,EAAA,CAAG,8EAA8E;IAC/E,MAAME,gBAAA,GAAmBC,OAAA,CAAQC,GAAG,CAACC,cAAc;IACnD,OAAOF,OAAA,CAAQC,GAAG,CAACC,cAAc;IAEjC,IAAI;MACF,MAAMC,cAAA,GAAiB;QACrBC,QAAA,EAAU;MACZ;MAEAN,WAAA,CAAYK,cAAA;MAEZ;MACAP,MAAA,CAAOI,OAAA,CAAQC,GAAG,CAACC,cAAc,EAAEG,IAAI,CAAC;IAC1C,UAAU;MACR;MACA,IAAIN,gBAAA,KAAqBO,SAAA,EAAW;QAClC,OAAON,OAAA,CAAQC,GAAG,CAACC,cAAc;MACnC,OAAO;QACLF,OAAA,CAAQC,GAAG,CAACC,cAAc,GAAGH,gBAAA;MAC/B;IACF;EACF;EAEAF,EAAA,CAAG,8EAA8E;IAC/E,MAAME,gBAAA,GAAmBC,OAAA,CAAQC,GAAG,CAACC,cAAc;IAEnD,IAAI;MACF,MAAMC,cAAA,GAAiB,CAAC;MAExBL,WAAA,CAAYK,cAAA;MAEZ;MACAP,MAAA,CAAOI,OAAA,CAAQC,GAAG,CAACC,cAAc,EAAEG,IAAI,CAACN,gBAAA;IAC1C,UAAU;MACR;MACA,IAAIA,gBAAA,KAAqBO,SAAA,EAAW;QAClC,OAAON,OAAA,CAAQC,GAAG,CAACC,cAAc;MACnC,OAAO;QACLF,OAAA,CAAQC,GAAG,CAACC,cAAc,GAAGH,gBAAA;MAC/B;IACF;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"withPayload.spec.js","names":["describe","expect","it","withPayload","originalBasePath","process","env","NEXT_BASE_PATH","mockNextConfig","basePath","toBe","undefined","originalTrailingSlash","NEXT_TRAILING_SLASH","trailingSlash"],"sources":["../../src/withPayload/withPayload.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { withPayload } from './withPayload.js'\n\ndescribe('withPayload', () => {\n it('should set process.env.NEXT_BASE_PATH when nextConfig.basePath is provided', () => {\n const originalBasePath = process.env.NEXT_BASE_PATH\n delete process.env.NEXT_BASE_PATH\n\n try {\n const mockNextConfig = {\n basePath: '/test/basepath',\n }\n\n withPayload(mockNextConfig)\n\n // Verify it set the env var so formatAdminURL can read it\n expect(process.env.NEXT_BASE_PATH).toBe('/test/basepath')\n } finally {\n // Restore original value\n if (originalBasePath === undefined) {\n delete process.env.NEXT_BASE_PATH\n } else {\n process.env.NEXT_BASE_PATH = originalBasePath\n }\n }\n })\n\n it('should not modify process.env.NEXT_BASE_PATH when basePath is not provided', () => {\n const originalBasePath = process.env.NEXT_BASE_PATH\n\n try {\n const mockNextConfig = {}\n\n withPayload(mockNextConfig)\n\n // Verify it didn't set the env var\n expect(process.env.NEXT_BASE_PATH).toBe(originalBasePath)\n } finally {\n // Restore original value\n if (originalBasePath === undefined) {\n delete process.env.NEXT_BASE_PATH\n } else {\n process.env.NEXT_BASE_PATH = originalBasePath\n }\n }\n })\n\n it('should mirror nextConfig.trailingSlash in process.env.NEXT_TRAILING_SLASH', () => {\n const originalTrailingSlash = process.env.NEXT_TRAILING_SLASH\n\n try {\n process.env.NEXT_TRAILING_SLASH = 'true'\n\n withPayload({ trailingSlash: false })\n expect(process.env.NEXT_TRAILING_SLASH).toBe('false')\n\n withPayload({ trailingSlash: true })\n expect(process.env.NEXT_TRAILING_SLASH).toBe('true')\n } finally {\n if (originalTrailingSlash === undefined) {\n delete process.env.NEXT_TRAILING_SLASH\n } else {\n process.env.NEXT_TRAILING_SLASH = originalTrailingSlash\n }\n }\n })\n})\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,WAAW,QAAQ;AAE5BH,QAAA,CAAS,eAAe;EACtBE,EAAA,CAAG,8EAA8E;IAC/E,MAAME,gBAAA,GAAmBC,OAAA,CAAQC,GAAG,CAACC,cAAc;IACnD,OAAOF,OAAA,CAAQC,GAAG,CAACC,cAAc;IAEjC,IAAI;MACF,MAAMC,cAAA,GAAiB;QACrBC,QAAA,EAAU;MACZ;MAEAN,WAAA,CAAYK,cAAA;MAEZ;MACAP,MAAA,CAAOI,OAAA,CAAQC,GAAG,CAACC,cAAc,EAAEG,IAAI,CAAC;IAC1C,UAAU;MACR;MACA,IAAIN,gBAAA,KAAqBO,SAAA,EAAW;QAClC,OAAON,OAAA,CAAQC,GAAG,CAACC,cAAc;MACnC,OAAO;QACLF,OAAA,CAAQC,GAAG,CAACC,cAAc,GAAGH,gBAAA;MAC/B;IACF;EACF;EAEAF,EAAA,CAAG,8EAA8E;IAC/E,MAAME,gBAAA,GAAmBC,OAAA,CAAQC,GAAG,CAACC,cAAc;IAEnD,IAAI;MACF,MAAMC,cAAA,GAAiB,CAAC;MAExBL,WAAA,CAAYK,cAAA;MAEZ;MACAP,MAAA,CAAOI,OAAA,CAAQC,GAAG,CAACC,cAAc,EAAEG,IAAI,CAACN,gBAAA;IAC1C,UAAU;MACR;MACA,IAAIA,gBAAA,KAAqBO,SAAA,EAAW;QAClC,OAAON,OAAA,CAAQC,GAAG,CAACC,cAAc;MACnC,OAAO;QACLF,OAAA,CAAQC,GAAG,CAACC,cAAc,GAAGH,gBAAA;MAC/B;IACF;EACF;EAEAF,EAAA,CAAG,6EAA6E;IAC9E,MAAMU,qBAAA,GAAwBP,OAAA,CAAQC,GAAG,CAACO,mBAAmB;IAE7D,IAAI;MACFR,OAAA,CAAQC,GAAG,CAACO,mBAAmB,GAAG;MAElCV,WAAA,CAAY;QAAEW,aAAA,EAAe;MAAM;MACnCb,MAAA,CAAOI,OAAA,CAAQC,GAAG,CAACO,mBAAmB,EAAEH,IAAI,CAAC;MAE7CP,WAAA,CAAY;QAAEW,aAAA,EAAe;MAAK;MAClCb,MAAA,CAAOI,OAAA,CAAQC,GAAG,CAACO,mBAAmB,EAAEH,IAAI,CAAC;IAC/C,UAAU;MACR,IAAIE,qBAAA,KAA0BD,SAAA,EAAW;QACvC,OAAON,OAAA,CAAQC,GAAG,CAACO,mBAAmB;MACxC,OAAO;QACLR,OAAA,CAAQC,GAAG,CAACO,mBAAmB,GAAGD,qBAAA;MACpC;IACF;EACF;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/next",
3
- "version": "3.90.1",
3
+ "version": "3.90.2",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -100,9 +100,9 @@
100
100
  "qs-esm": "8.0.1",
101
101
  "sass": "1.77.4",
102
102
  "uuid": "13.0.2",
103
- "@payloadcms/graphql": "3.90.1",
104
- "@payloadcms/translations": "3.90.1",
105
- "@payloadcms/ui": "3.90.1"
103
+ "@payloadcms/graphql": "3.90.2",
104
+ "@payloadcms/translations": "3.90.2",
105
+ "@payloadcms/ui": "3.90.2"
106
106
  },
107
107
  "devDependencies": {
108
108
  "@babel/cli": "7.27.2",
@@ -118,13 +118,13 @@
118
118
  "esbuild": "0.27.1",
119
119
  "esbuild-sass-plugin": "3.3.1",
120
120
  "swc-plugin-transform-remove-imports": "8.3.0",
121
- "payload": "3.90.1",
121
+ "payload": "3.90.2",
122
122
  "@payloadcms/eslint-config": "3.28.0"
123
123
  },
124
124
  "peerDependencies": {
125
125
  "graphql": "^16.8.1",
126
126
  "next": ">=15.2.9 <15.3.0 || >=15.3.9 <15.4.0 || >=15.4.11 <15.5.0 || >=16.3.3 <17.0.0",
127
- "payload": "3.90.1"
127
+ "payload": "3.90.2"
128
128
  },
129
129
  "engines": {
130
130
  "node": "^18.20.2 || >=20.9.0"