Unverified Commit d8d9b2c9 authored by Hannes Bornö's avatar Hannes Bornö Committed by GitHub

Remove app routes from _devPagesManifest (#43188)

Currently in dev the `_devPagesManifest` includes the `/app` routes as
well. However, In production, the `_buildManifest.js` does not include
the `/app` routes. This causes the `/pages` router to behave differently
in the two environments.

This change excludes the `/app` routes from `_devPagesManifest` to make
it work the same in dev/prod.

Fixes #42513
Fixes #42532

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent ee969ea8
...@@ -1226,7 +1226,9 @@ export default class DevServer extends Server { ...@@ -1226,7 +1226,9 @@ export default class DevServer extends Server {
res res
.body( .body(
JSON.stringify({ JSON.stringify({
pages: this.sortedRoutes, pages: this.sortedRoutes?.filter(
(route) => !this.appPathRoutes![route]
),
}) })
) )
.send() .send()
......
export default function Page() {
return (
<p id="app-text">
hello from app/dynamic-pages-route-app-overlap/app-dir/page
</p>
)
}
import Link from 'next/link'
export default function Page() {
return (
<Link id="pages-link" href="/dynamic-pages-route-app-overlap/app-dir">
To /dynamic-pages-route-app-overlap/app-dir
</Link>
)
}
export default function Page() {
return (
<p id="pages-text">
hello from pages/dynamic-pages-route-app-overlap/[slug]
</p>
)
}
...@@ -601,6 +601,29 @@ describe('app dir', () => { ...@@ -601,6 +601,29 @@ describe('app dir', () => {
await browser.close() await browser.close()
} }
}) })
it('should navigate to pages dynamic route from pages page if it overlaps with an app page', async () => {
const browser = await webdriver(
next.url,
'/dynamic-pages-route-app-overlap'
)
try {
// Click the link.
await browser.elementById('pages-link').click()
expect(await browser.waitForElementByCss('#pages-text').text()).toBe(
'hello from pages/dynamic-pages-route-app-overlap/[slug]'
)
// When refreshing the browser, the app page should be rendered
await browser.refresh()
expect(await browser.waitForElementByCss('#app-text').text()).toBe(
'hello from app/dynamic-pages-route-app-overlap/app-dir/page'
)
} finally {
await browser.close()
}
})
}) })
describe('server components', () => { describe('server components', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment