Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(client): address requested changes
Elian Doran7288b66d2732
diff --git a/apps/client/src/index.html b/apps/client/src/index.htmlindex a924d79eb5..b1541e784b 100644--- a/apps/client/src/index.html+++ b/apps/client/src/index.html@@ -5,7 +5,7 @@<link rel="shortcut icon" href="favicon.ico"><meta name="mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover" />+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover, interactive-widget=resizes-content" /><link rel="manifest" crossorigin="use-credentials" href="manifest.webmanifest"><title>Trilium Notes</title></head>@@ -15,7 +15,7 @@<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container" style="display: none"></div>- <!-- Required for match the PWA's top bar color with the theme -->+ <!-- Required to match the PWA's top bar color with the theme --><!-- This works even when the user directly changes --root-background in CSS --><div id="background-color-tracker" style="position: absolute; visibility: hidden; color: var(--root-background); transition: color 1ms;"></div>diff --git a/apps/client/src/index.ts b/apps/client/src/index.tsindex 8308395f58..795adc8cfd 100644--- a/apps/client/src/index.ts+++ b/apps/client/src/index.ts@@ -1,8 +1,10 @@async function bootstrap() {showSplash();- await initJQuery();await setupGlob();- await loadBootstrapCss();+ await Promise.all([+ initJQuery(),+ loadBootstrapCss()+ ]);loadStylesheets();loadIcons();setBodyAttributes();@@ -29,7 +31,7 @@ async function setupGlob() {async function loadBootstrapCss() {// We have to selectively import Bootstrap CSS based on text direction.- if (document.body.dir === "rtl") {+ if (glob.isRtl) {await import("bootstrap/dist/css/bootstrap.rtl.min.css");} else {await import("bootstrap/dist/css/bootstrap.min.css");@@ -58,7 +60,7 @@ function loadStylesheets() {const linkEl = document.createElement("link");linkEl.href = href;linkEl.rel = "stylesheet";- document.body.appendChild(linkEl);+ document.head.appendChild(linkEl);}}@@ -75,7 +77,7 @@ function setBodyAttributes() {`heading-style-${headingStyle}`,`layout-${layoutOrientation}`,`platform-${platform}`,- isElectron && "isElectron",+ isElectron && "electron",hasNativeTitleBar && "native-titlebar",hasBackgroundEffects && "background-effects"].filter(Boolean) as string[];diff --git a/apps/server/src/routes/assets.ts b/apps/server/src/routes/assets.tsindex eb10aca1c8..cc8847db19 100644--- a/apps/server/src/routes/assets.ts+++ b/apps/server/src/routes/assets.ts@@ -1,10 +1,13 @@import express from "express";+import rateLimit from "express-rate-limit";import { existsSync } from "fs";import path from "path";import type serveStatic from "serve-static";import { assetUrlFragment } from "../services/asset_path.js";+import auth from "../services/auth.js";import { getResourceDir, isDev } from "../services/utils.js";+import { doubleCsrfProtection as csrfMiddleware } from "./csrf_protection.js";const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<unknown, Record<string, unknown>>>) => {if (!isDev) {@@ -20,6 +23,11 @@ async function register(app: express.Application) {const srcRoot = path.join(__dirname, "..", "..");const resourceDir = getResourceDir();+ const rootLimiter = rateLimit({+ windowMs: 15 * 60 * 1000, // 15 minutes+ max: 100 // limit each IP to 100 requests per windowMs+ });+if (process.env.NODE_ENV === "development") {const { createServer: createViteServer } = await import("vite");const clientDir = path.join(srcRoot, "../client");@@ -32,7 +40,7 @@ async function register(app: express.Application) {css: { devSourcemap: true }});app.use(`/${assetUrlFragment}/`, vite.middlewares);- app.get(`/`, (req, res, next) => {+ app.get(`/`, [ rootLimiter, auth.checkAuth, csrfMiddleware ], (req, res, next) => {req.url = `/${assetUrlFragment}/src/index.html`;vite.middlewares(req, res, next);});@@ -47,7 +55,7 @@ async function register(app: express.Application) {throw new Error(`Public directory is missing at: ${path.resolve(publicDir)}`);}- app.get(`/`, (req, res) => {+ app.get(`/`, [ rootLimiter, auth.checkAuth, csrfMiddleware ], (_, res) => {// We force the page to not be cached since on mobile the CSRF token can be// broken when closing the browser and coming back in to the page.// The page is restored from cache, but the API call fail.