-
-
Notifications
You must be signed in to change notification settings - Fork 167
Fix(create-pages): Fix path matching precedence for api routes with wildcard routes #1451
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
Fix(create-pages): Fix path matching precedence for api routes with wildcard routes #1451
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Figured I'd try to implement a fix also, pushed a change here: 0805f30 to sort wildcard path configs to the end of the array so we match on them last. Not sure if this is a naive fix (and maybe leads to other issues), but it seems to make the most sense in that we should probably match explicit path specs first before falling back on wildcard route segments. cc @tylersayshi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is a naive fix (and maybe leads to other issues), but it seems to make the most sense in that we should probably match explicit path specs first before falling back on wildcard route segments.
It might make sense, but I would like to leave this responsibility for create-pages.ts. Can you modify create-pages.ts instead of define-router.ts?
@dai-shi got some time to take a look at the code again today - I don't think this can be solved for within One possible option could be to have After thinking about my naive solve here a bit more, an even simpler solve could be to move the api route spread here up above the page route spread. |
Ah I see what you mean. I think we should make some changes in define-router.ts. I can work on it later but not soon. |
I haven't started. Give me time. |
👉 #1487 |
Technically breaking change for unstable defineRouter. Related: #1451
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hamlim I'm sorry, but you seem to forget our previous conversation. #1451 (review)
The fix should be in create-pages.ts. Do not modify define-router.ts.
Sorry about that, updated the branch to apply the fix in If |
Record of flaky tests: https://github.com/wakujs/waku/actions/runs/15853235995/job/44691999735?pr=1451
https://github.com/wakujs/waku/actions/runs/15853235995/job/44691999777?pr=1451
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@tylersayshi Can you have another review?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest looks good 👍
…com/hamlim/waku into e2e-catch-all-overriding-api-routes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for all the reviews and feedback! |
This change sorts the path configs returned from the
getConfig
method passed tounstable_defineRouter
withincreatePages
, specifically sorting wildcard routes to the end of the list of path configs.Additionally this PR adds a previously failing e2e test for #1448, which now passes after the change.
Fixes: #1448