Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit c3fec95

Browse files
committed
refactor(cookiePath): remove non-working cookiePath option
this option will currently not work => the cookie will never be set by the server, if you use a different path other than "/" in order for this to work we would need to introduce some kind of "custom route prefix", that would make express serve the routes with the custom prefix — but that kinda falls more into a reverse proxy job territory. So let's remove this feature for now and amend the docs on how to correctly handle the cookies per instance via the reverse proxy.
1 parent 60217d4 commit c3fec95

4 files changed

Lines changed: 2 additions & 14 deletions

File tree

data-docs/config.ini

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ trustedReverseProxy=false
3030

3131

3232
[Session]
33-
# Use this setting to set a custom value for the "Path" Attribute value of the session cookie.
34-
# This can be useful, when you have several instances running on the same domain, under different paths (e.g. by using a reverse proxy).
35-
# It prevents your instances from overwriting each others' cookies, allowing you to stay logged in multiple instances simultanteously.
36-
# E.g. if you have instances running under https://your-domain.com/triliumNext/instanceA and https://your-domain.com/triliumNext/instanceB
37-
# you would want to set the cookiePath value to "/triliumNext/instanceA" for your first and "/triliumNext/instanceB" for your second instance
38-
cookiePath=/
39-
4033
# Use this setting to set a custom value for the "Max-Age" Attribute of the session cookie.
4134
# This controls how long your session will be valid, before it expires and you need to log in again, when you use the "Remember Me" option.
4235
# Value needs to be entered in Seconds.

src/routes/csrf_protection.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { doubleCsrf } from "csrf-csrf";
22
import sessionSecret from "../services/session_secret.js";
33
import { isElectron } from "../services/utils.js";
4-
import config from "../services/config.js";
54

65
const doubleCsrfUtilities = doubleCsrf({
76
getSecret: () => sessionSecret,
87
cookieOptions: {
9-
path: config.Session.cookiePath,
8+
path: "/",
109
secure: false,
1110
sameSite: "strict",
1211
httpOnly: !isElectron // set to false for Electron, see https://github.com/TriliumNext/Notes/pull/966

src/routes/session_parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const sessionParser = session({
1111
resave: false, // true forces the session to be saved back to the session store, even if the session was never modified during the request.
1212
saveUninitialized: false, // true forces a session that is "uninitialized" to be saved to the store. A session is uninitialized when it is new but not modified.
1313
cookie: {
14-
path: config.Session.cookiePath,
14+
path: "/",
1515
httpOnly: true,
1616
maxAge: config.Session.cookieMaxAge * 1000 // needs value in milliseconds
1717
},

src/services/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export interface TriliumConfig {
3131
trustedReverseProxy: boolean | string;
3232
};
3333
Session: {
34-
cookiePath: string;
3534
cookieMaxAge: number;
3635
};
3736
Sync: {
@@ -84,9 +83,6 @@ const config: TriliumConfig = {
8483
},
8584

8685
Session: {
87-
cookiePath:
88-
process.env.TRILIUM_SESSION_COOKIEPATH || iniConfig?.Session?.cookiePath || "/",
89-
9086
cookieMaxAge:
9187
parseInt(String(process.env.TRILIUM_SESSION_COOKIEMAXAGE)) || parseInt(iniConfig?.Session?.cookieMaxAge) || 21 * 24 * 60 * 60 // 21 Days in Seconds
9288
},

0 commit comments

Comments
 (0)