-
Notifications
You must be signed in to change notification settings - Fork 513
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
aws lambda-edge #79
Comments
Hi, I wonder if you have any ETA for this preset? |
@tresko I created the PR exactly at the moment you commented. LOL! The current escape hatch is to wrap an existing preset for Lambda@Edge. import { URLSearchParams } from "url";
import * as nitro from "./index.mjs";
export const handler = async (event) => {
const request = event.Records[0].cf.request;
const queryStringParameters = Object.fromEntries(
new URLSearchParams(request.querystring).entries()
);
const response = await nitro.handler({
path: request.uri,
queryStringParameters,
httpMethod: request.method,
headers: normalizeIncomingHeaders(request.headers),
body: request.body,
});
return {
status: response.statusCode,
headers: normalizeOutgoingHeaders(response.headers),
body: response.body,
};
};
function normalizeIncomingHeaders(headers) {
return Object.fromEntries(
Object.entries(headers).map(([key, keyValues]) => [
key,
keyValues.map((kv) => kv.value).join(","),
])
);
}
function normalizeOutgoingHeaders(headers) {
return Object.fromEntries(
Object.entries(headers).map(([key, values]) => [
key,
values.split(",").map((value) => ({ value })),
])
);
} Saving this code as |
@WinterYukky Wow, amazing! Thank you! I saw on your PR that you are using Nuxt3 on lambda@edge. Am I correct? Can you share a wrapper example for Nuxt 3? |
@tresko Yes. I'm using Nuxt3 on lambda@edge. I have created and published a simple project for you. I have included the deployment procedure at the end of ref: https://github.com/WinterYukky/nuxt3-lambda-edge-example |
@WinterYukky Thank you! |
@pi0 any plan to support this feature in the near future? |
Up, there are currently two PRs for this. It is very frustrating that @pi0 is not explaining why/what was wrong with the first one/ what are the technical difficulties/ what are higher priorities 😢 |
There's 2 PR Open for We could create 2 different presets, #1075 => Both preset should use the same entry for the runtime. There's also the option to have a single preset and a config flag such as The CDK version is useful for direct deploy, see here #1387 The non cdk version is useful to integrate with IAC deployment frameworks such as SST, Pulumi etc Tracked in Nitro : #133 |
Hello, I can see that this development has been stopped for a while. Is there any intention to finish it? I wanted to submit a PR for this, but there are many of them already.
Let me know if I can help speed this up to have it on the official repo. But, for now, I won't submit anything as the credits should go for the already opened ones. |
I think this hasn't been reviewed yet because it's low on the priority list. I left comments for @pi0 in #1557 about the 2 possible approaches. However I'm pretty sure SST has evolved since, so we would need to pin the compatible versions. |
Hello @Hebilicious, I have reviewed both PRs, and it will be very easy to get merged #1075; there are a few lines that need to be updated to make it work with the latest nitro version. After merging this, you can finish branch #1557, which seems way more complicated and, as you said, may need to be updated. For example, in my case, I use it to build a Solidjs app. In the new version 0.4.2, they have implemented Vinxi, which uses nitropack to build a solidjs app. Then I have my own CDK deployment script. So, having #1075 will be plug-and-play, while #1557 is irrelevant for my use case. This is an example. I'd be very happy to share my CDK script with you if that helps you finish #1557, but from what I see, the bottleneck comes from SST. My opinion on the matter: Having those three split may seem too much preset, but it will be clear, as my understanding. Let me know if you want me to help with anything! :) |
https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html
nuxt/nuxt#11700
The text was updated successfully, but these errors were encountered: