How to serve index.html file #1392
FromCppToCarbon
started this conversation in
General
Replies: 3 comments 2 replies
-
|
Here is an example: Bun.serve({
fetch(req) {
const url = new URL(req.url);
if (url.pathname.endsWith("/") || url.pathname.endsWith("/index.html"))
return new Response(Bun.file(import.meta.dir + "/index.html"));
// all other routes
return new Response("Hello!");
}
}); |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
is this what you are looking for? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
How to replicate |
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.
-
May i know how to serve index.html file in bun ? with advance thanks for the answer
Beta Was this translation helpful? Give feedback.
All reactions