fix: frontend router not found fix

This commit is contained in:
2024-03-16 10:40:17 +07:00
parent 99c479ade2
commit 4dfa1decfe
5 changed files with 18 additions and 10 deletions
+9 -2
View File
@@ -1,16 +1,23 @@
import "dotenv/config";
import { Hono } from "hono";
import { cors } from "hono/cors";
import fs from "node:fs";
import { HTTPException } from "hono/http-exception";
import { serveStatic } from "@hono/node-server/serve-static";
import { serve } from "@hono/node-server";
import routes from "./routes/_routes";
import createWsServer from "./websocket";
const PUBLIC_DIR = "./public";
const app = new Hono()
.use(cors())
.use("*", serveStatic({ root: "./public" }))
.route("/", routes)
.route("/api", routes)
.use("*", serveStatic({ root: PUBLIC_DIR }), async (c) => {
const index = fs.readFileSync(PUBLIC_DIR + "/index.html", "utf8");
c.header("Content-Type", "text/html");
return c.html(index);
})
.onError((err, c) => {
if (err instanceof HTTPException) {
return err.getResponse();
+1 -1
View File
@@ -32,6 +32,6 @@
</noscript>
<!-- The root element for your Expo app. -->
<div id="root"></div>
<script src="/_expo/static/js/web/entry-a989ba6dbc16efcaea6aa0b62000b62c.js" defer></script>
<script src="/_expo/static/js/web/entry-00f3c2d1c7f748816f9f7bad0e7a55f0.js" defer></script>
</body>
</html>