Closed pheekus closed 1 year ago
Hi, can you provide a small reproduction please ? I would like to know if you're doing all of this in an event handler and which methods you're using exactly.
@Hebilicious sure thing, I'll get you a test project to look at by the end of this week
@Hebilicious here's the repo, it's a heavily simplified version of the project I'm working on. I've included some comments on what it is and how it works in the readme: unjs-unenv-issue-118-demo.
This is a bit off-topic/cross-project BUT if anyone else experiences similar issues with headers/cookies/base64 in a nuxt3 app built with the aws-labmda
preset, a custom preset with serverless-http worked super well for me as a temporary solution:
preset/entry.ts:
import "#internal/nitro/virtual/polyfill";
import { toNodeListener } from "h3";
import serverless from "serverless-http";
const listener = toNodeListener(useNitroApp().h3App);
export const handler = serverless(listener, { provider: "aws" });
preset/nitro.config.ts:
import type { NitroPreset } from "nitropack";
import { fileURLToPath } from "node:url";
export default <NitroPreset>{
extends: "node-server",
entry: fileURLToPath(new URL("./entry.ts", import.meta.url)),
};
nuxt.config.ts:
nitro: {
preset: "./preset",
},
This seems to be intentional but it breaks compatibility with packages like node-oidc-provider that expect
response.getHeader()
to return the same data type as was passed toresponse.setHeader()
, which is what the node docs say should happen.For context, here's what happens in one of the projects I'm working on for a client. We're using nuxt3 deployed with the aws-lambda nitro preset. Several API routes pass ServerResponse instances from this framework to node-oidc-provider that sets multi-value set-cookie header in one module and reads it afterwards in another one. Since the original value is an array, it expects to receive an array back. Instead of that, it gets a comma-separated string and errors.
Relevant code is below. If this is the behaviour you're planning to keep, I'd appreciate a quick comment about that so I and everyone else who stumbles upon this issue can look into a workaround. Thanks :)
https://github.com/unjs/unenv/blob/82bdf72a5fd2ae38296afe48c340dc90c8b272dc/src/runtime/node/http/_response.ts#L98