Fix api route caching issue

This commit is contained in:
2026-04-11 10:00:24 +01:00
parent af8c207ac1
commit c4f7cf9164
43 changed files with 132 additions and 1316 deletions
+14 -2
View File
@@ -3,6 +3,9 @@ import grabConstants from "../../utils/grab-constants";
import grabRouter from "../../utils/grab-router";
import isDevelopment from "../../utils/is-development";
import _ from "lodash";
import path from "path";
import grabDirNames from "../../utils/grab-dir-names";
const { ROOT_DIR } = grabDirNames();
export default async function ({ req }) {
const url = new URL(req.url);
const is_dev = isDevelopment();
@@ -22,9 +25,18 @@ export default async function ({ req }) {
});
}
const routeParams = await grabRouteParams({ req });
let module;
const now = Date.now();
const import_path = is_dev ? `${match.filePath}?t=${now}` : match.filePath;
const module = await import(import_path);
if (global.SSR_BUNDLER_CTX_MAP?.[match.filePath]?.path) {
const target_import = path.join(ROOT_DIR, global.SSR_BUNDLER_CTX_MAP[match.filePath].path);
module = await import(`${target_import}?t=${now}`);
}
else {
const import_path = is_dev
? `${match.filePath}?t=${now}`
: match.filePath;
module = await import(import_path);
}
const config = module.config;
const contentLength = req.headers.get("content-length");
if (contentLength) {