Comments (9)
yes it is. but i doubt fixing the dev server will be easier. this is a 3 lines patch which can be applied with patch-package and gives the hand to userland through the middleware. so i think it's pretty ok until the maintainers finally decide to have a look at this. (cc @leerob i had mentioned this to you on X)
from next.js.
yeah - its' not a trivial fix. let's see what happens with this
from next.js.
somehow related: #53887
from next.js.
looking further, the regexes generated for the routes seem to ignore totally the generateStaticParams
from next.js.
after a good round of console.log
(and from my candid PoV of next), it seems like the AppPageRouteMatcher
does not contain data from getStaticParams
, therefore it's impossible to get an accurate route matching.
Route definition is passed here, but lacks of any kind of ref to getStaticParams
:/
from next.js.
of course i want to state clear that i know this:
but still routes imho should abide to the result of this function and pass to other matchers before making a decision. here is seems the logic is → match the path blindly regardless of the values in params, then render the route no matter what.
it's utterly deceptive because it's like not using a data validation library (the valid values returned from generateStaticParams
) and then pass unvalidated/wrong values to a component.
from next.js.
good find, @y-nk.. I'm looking into this and found out that this only happens in dev mode. Production build works as expected. The issue you linked has a PR by one of the maintainers: #54364 - I this issue is stemming from the code changes here. Will investigate further.
Update: this has nothing to do with this PR. The behaviour of the generateStaticParams
function in dev mode as you highlighted above is the reason for this issue. The route regex being made does not take into consideration the static params for a given page. It just creates those regexes based on the folder structure. I'm not sure if the maintainers would want to change this behaviour :/
from next.js.
@abhi12299 i have found an (slightly ugly) way to make it work, which i think could be used as a "ultimate manual mode" feature.
currently my idea is to add some code for manual/force route matching based on headers here:
next.js/packages/next/src/server/lib/router-utils/resolve-routes.ts
Lines 264 to 272 in a5f30e6
such as:
for (const route of dynamicRoutes) {
if (req.headers['x-resolved-route']) {
// skip the desired route was provided in headers
if (route.page !== req.headers['x-resolved-route']) {
continue;
}
}
then we can add this internal header in the middleware like this:
from next.js.
This is equivalent to hard coding the route match rules in the codebase.
from next.js.
Related Issues (20)
- With the `experimental-https` and `-H` options, the next dev will show a different URL
- Docs: Improve scripts
- Docs: NextImage document for png file
- Failed to find action after updating to `[email protected]` HOT 2
- next/link sometimes does not update the page when used in dynamic page with replace and query parameters in v15 HOT 1
- Dockerfile example is not working HOT 1
- Wrong `error.tsx` matched using both parallel and dynamic routes
- SyntaxError with Middle Dot (U+30FB) as Object Key in Older iOS Safari Versions
- Standalone Output doesn't work with PNPM HOT 7
- Trying to load a browser-only module on non-browser environment HOT 2
- Nextjs includes all client components in the bundle when at least one client component is rendered from a server component (app-folder) HOT 8
- Localized Sitemap Not Generating Proper XML Format HOT 1
- `fetch` having a different behavior on Vercel with input request
- Camel Casing Route Handler Folder Names HOT 1
- `<details>` element behaves differently in React/HTML compared to Next.js 14/15 HOT 2
- `<details>` element behaves incorrectly in Next.js 14/15 HOT 3
- Failed to find Server Action - next dev - v14.2.8 HOT 2
- HTTP Error 500.1002 - Internal Server Error HOT 1
- Relay compiler configuration "exclude" option is not respected HOT 2
- Scroll restoration issue. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next.js.