fix(server): proxying of inner client modules

This commit is contained in:
Elian Doran 2025-05-16 22:10:02 +03:00
parent e28a64a037
commit d4dbe1cb89
No known key found for this signature in database
2 changed files with 11 additions and 1 deletions

View File

@ -7,6 +7,7 @@ const assets = [ "assets", "stylesheets", "libraries", "fonts", "translations" ]
export default defineConfig(() => ({
root: __dirname,
base: "/assets/v0.94.0/app/",
cacheDir: '../../node_modules/.vite/apps/client',
server: {
port: 4200,

View File

@ -29,7 +29,16 @@ async function register(app: express.Application) {
throw new Error("Missing TRILIUM_PUBLIC_SERVER");
}
const clientProxy = proxy(publicUrl);
const clientProxy = proxy(publicUrl, {
proxyReqPathResolver: (req) => {
let url = req.url;
url = url.replace(/^\/src/, "/");
url = "/assets/v0.94.0/app/src" + url;
url = url.replace(/.js$/, ".ts");
console.log(`${req.url} => ${publicUrl}${url}`);
return url;
}
});
app.use(`/${assetPath}/app/doc_notes`, persistentCacheStatic(path.join(srcRoot, "assets", "doc_notes")));
app.use(`/${assetPath}/app`, clientProxy);
app.use(`/${assetPath}/app-dist`, clientProxy);