diff --git a/packages/next/src/build/webpack/plugins/flight-manifest-plugin.ts b/packages/next/src/build/webpack/plugins/flight-manifest-plugin.ts index 6afe89541969c..7b7d246a9a87c 100644 --- a/packages/next/src/build/webpack/plugins/flight-manifest-plugin.ts +++ b/packages/next/src/build/webpack/plugins/flight-manifest-plugin.ts @@ -16,6 +16,7 @@ import { getProxiedPluginState } from '../../build-context' import { nonNullable } from '../../../lib/non-nullable' import { WEBPACK_LAYERS } from '../../../lib/constants' +import { normalizePagePath } from '../../../shared/lib/page-path/normalize-page-path' interface Options { dev: boolean @@ -394,12 +395,18 @@ export class ClientReferenceManifestPlugin { const json = JSON.stringify(mergedManifest) const pagePath = groupName.replace(/%5F/g, '_') - assets['server/' + pagePath + '_' + CLIENT_REFERENCE_MANIFEST + '.js'] = - new sources.RawSource( - `globalThis.__RSC_MANIFEST=(globalThis.__RSC_MANIFEST||{});globalThis.__RSC_MANIFEST[${JSON.stringify( - pagePath.slice('app'.length) - )}]=${JSON.stringify(json)}` - ) as unknown as webpack.sources.RawSource + const pageBundlePath = normalizePagePath(pagePath.slice('app'.length)) + assets[ + 'server/app' + + pageBundlePath + + '_' + + CLIENT_REFERENCE_MANIFEST + + '.js' + ] = new sources.RawSource( + `globalThis.__RSC_MANIFEST=(globalThis.__RSC_MANIFEST||{});globalThis.__RSC_MANIFEST[${JSON.stringify( + pagePath.slice('app'.length) + )}]=${JSON.stringify(json)}` + ) as unknown as webpack.sources.RawSource if (pagePath === 'app/not-found') { // Create a separate special manifest for the root not-found page. diff --git a/packages/next/src/server/future/normalizers/built/app/app-bundle-path-normalizer.ts b/packages/next/src/server/future/normalizers/built/app/app-bundle-path-normalizer.ts index 1ff9f1e242330..815ce92f92726 100644 --- a/packages/next/src/server/future/normalizers/built/app/app-bundle-path-normalizer.ts +++ b/packages/next/src/server/future/normalizers/built/app/app-bundle-path-normalizer.ts @@ -1,6 +1,7 @@ import { Normalizers } from '../../normalizers' import { Normalizer } from '../../normalizer' import { PrefixingNormalizer } from '../../prefixing-normalizer' +import { normalizePagePath } from '../../../../../shared/lib/page-path/normalize-page-path' export class AppBundlePathNormalizer extends PrefixingNormalizer { constructor() { @@ -8,7 +9,7 @@ export class AppBundlePathNormalizer extends PrefixingNormalizer { } public normalize(page: string): string { - return super.normalize(page) + return super.normalize(normalizePagePath(page)) } } diff --git a/test/e2e/app-dir/app-edge/app-edge.test.ts b/test/e2e/app-dir/app-edge/app-edge.test.ts index b78e81f7d0f6d..d9e53aa9cde5b 100644 --- a/test/e2e/app-dir/app-edge/app-edge.test.ts +++ b/test/e2e/app-dir/app-edge/app-edge.test.ts @@ -21,6 +21,11 @@ createNextDescribe( expect(await res.text()).toInclude('Hello') }) + it('should handle /index routes correctly', async () => { + const appHtml = await next.render('/index') + expect(appHtml).toContain('the /index route') + }) + if ((globalThis as any).isNextDev) { it('should resolve module without error in edge runtime', async () => { const logs = [] diff --git a/test/e2e/app-dir/app-edge/app/index/page.js b/test/e2e/app-dir/app-edge/app/index/page.js new file mode 100644 index 0000000000000..845f15e9b4616 --- /dev/null +++ b/test/e2e/app-dir/app-edge/app/index/page.js @@ -0,0 +1,5 @@ +export default function Page() { + return

the /index route

+} + +export const runtime = 'edge'