-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Closed
Description
Hey 👋
Thank you a lot @timneutkens for great #5927 PR, amazing work 🥇
I was going through the code of your PR in order to make it work with AWS Lambda and it was pretty straightforward.
I had to "hack" your next-serverless-loader.ts
function in order to be able to inject serverless-http
module that way:
// next.config.js
const nextServerlessLoader = require("next/dist/build/webpack/loaders/next-serverless-loader");
const { stripIndent } = require("common-tags");
const originalLoader = Object.assign(
{},
{ default: nextServerlessLoader.default }
);
nextServerlessLoader.default = function() {
const transformed = originalLoader.default
.call(this)
.replace(`export async function render`, `async function nextRender`);
const result = stripIndent`
import serverlessHttp from 'serverless-http';${transformed}
export const render = serverlessHttp(nextRender);
`;
return result;
};
module.exports = {
target: "serverless"
}
This is working great, the output can be directly plugged to an handler 🏆
functions:
index:
handler: .next/serverless/pages/index.render
events:
- http: GET /
Here are my questions:
- Are you willing to support other platforms than now.sh?
- If yes could we expose an option to auto-import the
serverless-http
module? - If not, should I write a custom plugin to nextjs?
Cheers ✌️
oliviertassinari, Vadorequest, rajington, vladholubiev, zachabney and 3 more
Metadata
Metadata
Assignees
Labels
No labels