BackendStack21 / 0http-bun

Bun-based HTTP framework inspired by 0http
MIT License
4 stars 1 forks source link

Nested router not work #5

Open SaltFish001 opened 3 weeks ago

SaltFish001 commented 3 weeks ago
import http from "0http-bun";
import nested from "0http-bun/lib/router/sequential";
import { renderToReadableStream } from "react-dom/server";
import App from "./views";

const { router } = http({
  port: 3000,
});
const test2 = nested();

test2.get("/test", () => {
  return Response.json({ hello: "hello" });
});
router.use("/api", test2);

router.get("/", async (_req) => {
  // jump to view page
  return Response.redirect("/view");
});
router.get("/view", async (_req) => {
  const stream = await renderToReadableStream(<App name="World" />);
  return new Response(stream, {
    headers: { "Content-Type": "text/html" },
  });
});

export default router;

but i got this: image

SaltFish001 commented 3 weeks ago

6