From 626e321f5232cc3a334deb53e06171e7d0c8a2cc Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 17 May 2025 10:50:52 +0300 Subject: [PATCH] fix(math): proxying of fonts --- apps/server/src/routes/assets.ts | 12 ++++-------- apps/server/webpack.config.cjs | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/apps/server/src/routes/assets.ts b/apps/server/src/routes/assets.ts index 220f1fe99..eda10773b 100644 --- a/apps/server/src/routes/assets.ts +++ b/apps/server/src/routes/assets.ts @@ -4,6 +4,7 @@ import { fileURLToPath } from "url"; import express from "express"; import { getResourceDir, isDev } from "../services/utils.js"; import type serveStatic from "serve-static"; +import proxy from "express-http-proxy"; const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions>>) => { if (!isDev) { @@ -24,6 +25,9 @@ async function register(app: express.Application) { if (!publicUrl) { throw new Error("Missing TRILIUM_PUBLIC_SERVER"); } + app.use(`/@fs`, proxy(publicUrl, { + proxyReqPathResolver: (req) => `/@fs` + req.url + })) } else { const clientStaticCache = persistentCacheStatic(path.join(resourceDir, "public")); app.use(`/${assetPath}/app`, clientStaticCache); @@ -47,14 +51,6 @@ async function register(app: express.Application) { app.use(`/node_modules/@excalidraw/excalidraw/dist/fonts/`, express.static(path.join(nodeModulesDir, "@excalidraw/excalidraw/dist/prod/fonts/"))); app.use(`/${assetPath}/node_modules/@excalidraw/excalidraw/dist/fonts/`, persistentCacheStatic(path.join(nodeModulesDir, "@excalidraw/excalidraw/dist/prod/fonts/"))); - // KaTeX - app.use(`/${assetPath}/node_modules/katex/dist/katex.min.js`, persistentCacheStatic(path.join(nodeModulesDir, "katex/dist/katex.min.js"))); - app.use(`/${assetPath}/node_modules/katex/dist/contrib/mhchem.min.js`, persistentCacheStatic(path.join(nodeModulesDir, "katex/dist/contrib/mhchem.min.js"))); - app.use(`/${assetPath}/node_modules/katex/dist/contrib/auto-render.min.js`, persistentCacheStatic(path.join(nodeModulesDir, "katex/dist/contrib/auto-render.min.js"))); - // expose the whole dist folder - app.use(`/node_modules/katex/dist/`, express.static(path.join(nodeModulesDir, "katex/dist/"))); - app.use(`/${assetPath}/node_modules/katex/dist/`, persistentCacheStatic(path.join(nodeModulesDir, "katex/dist/"))); - app.use(`/${assetPath}/node_modules/jquery/dist/`, persistentCacheStatic(path.join(nodeModulesDir, "jquery/dist/"))); app.use(`/${assetPath}/node_modules/jquery-hotkeys/`, persistentCacheStatic(path.join(nodeModulesDir, "jquery-hotkeys/"))); diff --git a/apps/server/webpack.config.cjs b/apps/server/webpack.config.cjs index 509446bd3..e2baf752e 100644 --- a/apps/server/webpack.config.cjs +++ b/apps/server/webpack.config.cjs @@ -14,7 +14,6 @@ function buildFilesToCopy() { const nodePaths = [ "@excalidraw/excalidraw/dist/prod/fonts/", - "katex/dist", "jquery/dist", "jquery-hotkeys", "jquery.fancytree/dist",