Next.js 8.0 just introduced a new target: "serverless"
config setting, described on this blog post. I set up a basic hello world app (here) to test it out. Copy-pasted the output of .next/serverless/pages/index.js
to a Google Cloud Function (their equivalent of AWS Lambda) and had it call render()
as outlined in the above blog post.
The problem I run into is that the page itself renders fine, but then it tries to fetch static assets (script files) at the same domain as the lambda, which of course doesn't work because there's nothing there but the lambda script.
You can see this happening here:
The idea I was going for was to use this new feature of Next.js to implement a micro-frontend architecture. Each page in pages/
could have its own development team / lifecycle, and be scaled accordingly on the backend. That is one of the main selling points of this feature, right?
What is the standard way of solving this? Do I need to set up a separate server for the static assets? Then put both behind a load balancer or router of some sort? If so, doesn't that defeat the purpose of using this to develop micro-frontends, since the static assets would include "index.js", "about.js", and script files for each page, and would need to be redeployed any time any page is updated?
Hope what I'm saying makes sense. Any help appreciated!