-
Notifications
You must be signed in to change notification settings - Fork 65
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
Pattern match not working #131
Comments
If that is the case, it seems to be a Next.js issue since it is not deterministic in deciding whether to run all.js or [slug].js. Try not using next-connect to see if the issue persists |
I tried to not use next-connect and it works fine.
…On Sun, Apr 11, 2021, 7:58 AM Hoang ***@***.***> wrote:
If that is the case, it seems to be a Next.js issue since it is not
deterministic in deciding whether to run all.js or [slug].js. Try not using
next-connect to see if the issue persists
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#131 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFP67SPKZY6FHPO7M63QVFLTIGFHBANCNFSM42T4LN4Q>
.
|
Can you please provide a minimal reproduction? Thanks! |
I will send it to you next week. Just want to fix few bugs. |
Think I stumbled upon the same problem, where I tried to defined a sub-route along other methods in one handler:
const handler = nc<NextApiRequest, NextApiResponse>({ onError, onNoMatch })
.use(authorizedRoute)
.get(getProfile)
.put(updateProfile)
.put("/specific-route", specificHandler)
.delete(deleteProfile) This didn't work and resulted that calling To fix it I kept the |
Hope this helps: catch-allif i have a route like
optinal catch-allif i have a route like
So far my best bet would be to follow // /api/users/[...slug].js
1- const handler = nc();
2-
3- handler.use('/api/users/, rootMiniapp);
4- handler.use('/api/users/:id', idMiniApp);
5- handlers.use('/api/users/somethingelse', otherMiniapp);
6-
7- export default handler this caused all possible urls to fall under this route as if they were all accepted . Hence, Also i tried to apply a midlleware to descide if the requested url actually is among the ones we use and otherwise error out with 404 but this was not ideal and caused to to try to end request from two different places and issue an error. Please if you find this useless or have a better solution, i am looking forward to know more about it. Note: See this repo Here |
Stumble across this issue where i have 2 distinct route but the result will randomly return from either one of the route. (Fetching from postman) Kinda positive that the pattern matching is somewhat buggy. The route:
|
I think I also have this problem, structure of my project is as following:
The weird problem is that when I deploy it, at first there is no problem, but after sometime my |
You need to put "[param].ts" into it's own folder so Next.js won't confuse it for any other route. |
I need it to be in the same folder to handle routes other than |
I am trying to integrate next-connect into my project but for some reason I am not getting consistent results while calling the endpoint. Here is the structure of the endpoints I am calling pages->api->category . Within category folder I have following files
index.js - http://localhost:3000/api/category
all.js - http://localhost:3000/api/category/all
[slug].js - http://localhost:3000/api/category/slug
While I am fetching GET- http://localhost:3000/api/category/all
for some reason I am getting GET- http://localhost:3000/api/category/slug
which is the wrong one. Nine times out of ten I am hitting the right endpoint.
Here is the apiRoute
The text was updated successfully, but these errors were encountered: