Serverless-next.js: Support for catch all routes

Created on 29 Jan 2020  路  9Comments  路  Source: serverless-nextjs/serverless-next.js

Is your feature request related to a problem? Please describe.
Next.js supports catch all routes routing (https://nextjs.org/docs/routing/dynamic-routes#catch-all-routes). This is not supported yet, instead I receive a 404.

Describe the solution you'd like
Support for catch all dynamic routes

Most helpful comment

Thanks to your hint I found the cause of the issue. I created a PR for it with the aws-lambda-crew: https://github.com/serverless-components/aws-lambda/pull/26

All 9 comments

Also just run in this issue - here is a detailed description of the new next.js-feature: https://nextjs.org/blog/next-9-2#catch-all-dynamic-routes

Hi folks, just published @1.9.1 with support for this 馃檶

Looks really great, but I can't seem to get it to work for API-routes: https://nextjs.org/docs/api-routes/dynamic-api-routes#catch-all-api-routes

My file is pages/api/[...path].js locally, but it's missing in the API-lambda. Other API-paths still work though.

Looks really great, but I can't seem to get it to work for API-routes: https://nextjs.org/docs/api-routes/dynamic-api-routes#catch-all-api-routes

My file is pages/api/[...path].js locally, but it's missing in the API-lambda. Other API-paths still work though.

There seems to be a problem with file names like [...whatever].js not getting uploaded to AWS Lambda. I can definitely see the built file by the component, e.g. .serverless_nextjs/api-lambda/[...path].js but for some reason it doesn't get uploaded to the Lambda. Maybe is an issue in https://github.com/serverless-components/aws-lambda/ which is actually what handles the zipping of the artifact and uploading but I had a look there and couldn't find anything obvious.
The reason why it worked last night for me it was because I was testing using a statically optimised catch all route which works fine as is just an HTML file uploaded to S3 but SSR pages or API pages don't seem to work atm.
Will keep digging see if I can get to the bottom of it. One possible fix may be to strip the catch all file names from the triple dots and replace with something safe but I'd prefer avoiding that if possible.

@danielcondemarin Thank you so much! I appreciate that 馃槉

Let me know if I can help somehow? I have no experience with serverless, but maybe I can help anyways?

Without any insight into the inner workings of the aws-lambda-component, I would guess that there's some path resolution algorithm that's trying to resolve the path and failing at that. E.g. trying to resolve /api/[...path].js by doing something like /api/[ + .. + .path].js and then erroring out because path /api/[ doesn't exist.

What do you think?

Thanks to your hint I found the cause of the issue. I created a PR for it with the aws-lambda-crew: https://github.com/serverless-components/aws-lambda/pull/26

I also was hit by this. Using the latest version of globby in aws-lambda will also fix this.

So what's the recommended approach here? I have an SSR'd pages/blog/[...all].js file that is giving me cloudfront 503s.

I am pleased to announce I've just released [email protected] which completes this work 馃帀

Was this page helpful?
0 / 5 - 0 ratings