-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Merge headers #405
Comments
Maybe something like this: const sendRemixResponse = async <Server extends HttpServer>(
reply: FastifyReply<Server>,
nodeResponse: Response,
): Promise<void> => {
reply.status(nodeResponse.status);
for (const [key, values] of nodeResponse.headers.entries()) {
// https://github.com/mcansh/remix-fastify/issues/405#issue-2471580896
if (key.toLowerCase() === 'link') {
const existingLinkValues = reply.getHeader('link');
if (typeof existingLinkValues === 'string') {
// We prepend Fastify headers rather than appending them because
// Remix's `Link` header is more likely to contain route-specific
// links, e.g. images. Meanwhile, Cloudflare appear to limit
// the number of links that it extracts to Early Hints.
reply.headers({ [key]: values + ', ' + existingLinkValues });
} else {
reply.headers({ [key]: values });
}
} else {
reply.headers({ [key]: values });
}
}
if (nodeResponse.body) {
const stream = responseToReadable(nodeResponse.clone());
return reply.send(stream);
}
return reply.send(await nodeResponse.text());
}; |
hey @lilouartz thanks for info i'll poke around soon |
|
If I am reading this correctly, I am not sure if this desired behavior beyond |
These seems to be an issue, where if I send headers using Fastify, then anything that gets added by Remix is overriden, e.g.
Here I am adding
link
header:but the loaded route also send
link
header, which overrides my value from the above.I would expect headers such as
link
to be merged.The text was updated successfully, but these errors were encountered: