How to serve index.html file #1392
FromCppToCarbon
started this conversation in
General
Replies: 2 comments 1 reply
-
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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