sladg / nextjs-lambda

Lambda deployments for Nextjs12 & Nextjs13 (standalone). Easy CLI commands to get your standalone Next output to run in AWS Lambda (not @Edge)! Uses CDK in behind and produces code zips importable to Terraform, Serverless, Azure, etc.
MIT License
169 stars 19 forks source link

Add support for basePath variable #44

Closed john-tipper closed 1 year ago

john-tipper commented 1 year ago

Fix #43

See #43 for detailed discussion of issue.

This PR allows users to specify an optional basePath which will be removed from request paths before the requests are passed to Nextjs within the server-handler lambda. This will allow for the server-handler lambda to be served on the same APIG as other lambdas without conflict, where each has a path prefix, e.g. /server and /image.

There is a PR of mine that been merged into serverless-http has not yet been released, which adds the basePath property into the Options Typescript type definition. Until that occurs, the rollup command fails because it performs Typescript checking. To avoid this failure, this PR adds a temporary @ts-ignore to ignore this issue. This line can be removed when the next version of serverless-http is released with my PR in it.

john-tipper commented 1 year ago

A new version of serverless-http has been release with my PR in it, which fixes the Typescript issue, so there is no need for the @ts-ignore workaround.

sladg commented 1 year ago

All good! Thanks!