Handle browser Errors.

This commit is contained in:
2026-03-21 06:34:32 +01:00
parent d893a31d73
commit 7ef114ee70
97 changed files with 849 additions and 277 deletions
+9 -3
View File
@@ -1,8 +1,10 @@
import grabRouteParams from "../../utils/grab-route-params";
import grabConstants from "../../utils/grab-constants";
import grabRouter from "../../utils/grab-router";
export default async function ({ req, server }) {
import isDevelopment from "../../utils/is-development";
export default async function ({ req }) {
const url = new URL(req.url);
const is_dev = isDevelopment();
const { MBInBytes, ServerDefaultRequestBodyLimitBytes } = grabConstants();
const router = grabRouter();
const match = router.match(url.pathname);
@@ -19,7 +21,9 @@ export default async function ({ req, server }) {
});
}
const routeParams = await grabRouteParams({ req });
const module = await import(match.filePath);
const now = Date.now();
const import_path = is_dev ? `${match.filePath}?t=${now}` : match.filePath;
const module = await import(import_path);
const config = module.config;
const contentLength = req.headers.get("content-length");
if (contentLength) {
@@ -40,7 +44,9 @@ export default async function ({ req, server }) {
}
const res = await module["default"]({
...routeParams,
server,
});
if (is_dev) {
res.headers.set("Cache-Control", "no-cache, no-store, must-revalidate");
}
return res;
}