-
Notifications
You must be signed in to change notification settings - Fork 26.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App router doesn't work when using pageExtensions config for Pages router #51478
Comments
Any plans to address this? If not, please update the docs so they don't give the impression that |
I am hoping have flag to exclude |
Ran into this as well, it's a big pitfall during migration since it's not mentioned in the migration guide, and is definitely an unexpected side-effect of having that setting. I don't think anyone would really want that setting to apply to app router, since the only reason it was necessary before is because the pages router treated every file as a route unless that setting was set. Now that we have magic filenames like |
Just want to note that we are on next@14, we use app router, no pages. We actively use pageExtensions and having no issues with it. And this setting is essential for us. It's the only way we found to replace/remove pages from build based on env settings. |
@vdanchenkov can you share an example config that works for you? Trying to do the same but can't get it to work. |
The error
occurs only if you have a single entry in pageExtensions
Hopefully the issue will be fixed once this PR is merged |
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #22 SMP Tue Jan 10 18:39:00 UTC 2023 Binaries: Node: 16.17.0 npm: 8.15.0 Yarn: 1.22.19 pnpm: 7.1.0 Relevant packages: next: 13.4.7-canary.1 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 4.9.5
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue or a replay of the bug
https://codesandbox.io/p/sandbox/laughing-booth-7z2m98?file=%2Fnext.config.js%3A1%2C1
To Reproduce
pageExtensions
option innext.config.js
to add a custom extension, as in the pages router docs. Any extension can be used, e.g.custom.tsx
pages
directory, using the configured extension to verify the router is working. E.g.pages/mypage.custom.tsx
app
directory and create a new page, e.g.app/myotherpage/page.tsx
app
pages are not working 🐛Going further:
app
directory to use the custom extensionapp/myotherpage/page.tsx
toapp/myotherpage/page.custom.tsx
pageExtensions.map is not a function
is triggeredDescribe the Bug
Pages in the
app
directory are not recognised if thepageExtensions
config is being used. Trying to access them render a 404 error page.Attempting to rename the
app
page to use the same custom extension set for thepages
router in thepageExtensions
config (e.g.app/myotherpage/page.custom.tsx
) results in the errorpageExtensions.map is not a function
.Disabling the
pageExtensions
config and renaming thepages
router pages to remove the custom extensions is a workaround that allows both routers to coexist as expected. In a real legacy app that would probably require the entire pages directory to be refactoredExpected Behavior
The
app
router pages should be able to coexist with thepageExtensions
option enabled to allow a smoother gradual migration (as recommended by the docs) of legacy apps that still heavily rely on custom pages extensions.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: