-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Documentation "highly recommends" an undocumented feature: serverless target #20487
Comments
Well, I am a bit disappointed this is solved by deleting the whole I guess the |
The general problem is that we've seen tons of people add Overall the TLDR is:
|
Thank you very much for sharing this, I understand. In the future, if you can write (not necessarily in the official doc) about what is needed for non-monolithic deployment, I think that would be great, so that nextjs really remains deployment-platform agnostic (in serverless mode). Right now, following the documentation, either you go to Vercel or you have to find an always running nodejs server - therefore excluding the benefits of serverless deployments which are far more convenient (be it on Amazon or Google or Microsoft for instance). Like I said in my original report, this would include how to use the per-page modules produced by the |
@timneutkens 👋 |
@ryands17 - with the AWS Lambda Container Images feature you can now host an entire classic express/nodejs/next application in the lambda runtime - former size limitations wrt the deployment package are removed. You still will need to bridge (or translate) the Lambda event mechanics to be express compatible - I regularly use serverless-express. And just for sake of clarity AWS Lambda isnt (really) a supported origin target for CF, so you need a conduit: either API Gateway or Application Load Balancer between them. |
@PeterAronZentai Thanks for the reply! Based on this comment, would it be ideal to still use the |
@ryands17 - I have actually built my suggested setup over the weekend - fullblown Next.js installation + convential Lambda + as Container Image, then I did a load test to see warmup times, and I am quite happy with the results. I am now putting together a repo plus some README to share how to do it. As for running Next.js in LambdaEdge - I tried that with target:serverless a while back, worked ok, and while it was an interesting experience, I felt that it was a hack as well. LambdaEdge has severe limitations compared to just Lambdas (for example: you cannot use env, you cannot use container images, and you are tied to the us-east-1 region, etc). - I think LambdaEdge wasnt invented for running webservers. My next is looking into Next.js 12's extra build outputs to see how those files could be utilised to get to a single file setup. Maybe a custom lambda host has some play in this. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
From the documentation:
It is explained that the
serverless
target will output autonomous modules, one per page, which export kind of wrappers around the http framework and therefore can be used in any cloud serverless function provider (e.g. Google Cloud Functions).This does work indeed, but then the client code tries to fetch
_next/data/{buildID}/{somepage}.json
which the documentation doesn't mention.Therefore, the documentation highly recommends an undocumented feature, which is confusing.
To Reproduce
serverless
target and use the generated modulesrender
method of (for instance)index.js
from the build output in.next/serverless/pages/
in the code of a function of your favorite serverless function cloud provider (e.g. Google Cloud Functions).next/static
in a_next/static
folder so thatexample.com/static/
uses it, and haveexample.com/
be served by the cloud function/another
to another cloud function which usesrequire('serverless/another.js').default.render
example.com
in the browser and in the console watch the browser fail to fetch_next/data/{buildID}/another.json
and force a full reload by redirecting to /another instead of using client-side routing navigationExpected behavior
serverless
configuration: access to disk for caching (and how to disable it in next.config.js), routes to be setup for_next/data
and methods to be used (renderReqToHTML
?): not documenting this makes theserverless
target kind of pointless while you highly recommend it in the same timeSystem information
N/A (applies to all systems)
The text was updated successfully, but these errors were encountered: