How to serve a bundle with custom headers #20691
cristiano-belloni
started this conversation in
General
Replies: 1 comment 1 reply
-
Hi. You can use "/*": new Response(Bun.file('./index.html'), {
headers: {
"Content-Type": "text/html",
"My-Header": "Hey",
},
}) But if you want to keep the automatic bun bundle, use nginx to add headers. Or try self proxy hack (bad example): import index from './index.html'
const PORT = 3000
Bun.serve({
routes: {
"/indexoriginal/": index,
"/": async (req) => {
return new Response(await (await fetch(`http://localhost:${PORT}/indexoriginal/`)).text(), {
headers: {
"Content-Type": "text/html",
"My-Header": "Hey",
},
})
},
}, |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If I'm serving a HTML bundle:
there seems to be no way of specifying a custom header. I tried to do
but it doesn't work. What is the idiomatic way to do this?
Beta Was this translation helpful? Give feedback.
All reactions