mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-01 18:31:31 +08:00
chore: fix TS warning by type narrowing
`req.csrfToken` might be undefined according to `csrf-csrf` provided types, so use type narrowing to make sure it exists, before calling it
This commit is contained in:
parent
d20a3bab2a
commit
c36085e580
@ -19,7 +19,7 @@ function index(req: Request, res: Response) {
|
|||||||
|
|
||||||
const view = !utils.isElectron() && req.cookies["trilium-device"] === "mobile" ? "mobile" : "desktop";
|
const view = !utils.isElectron() && req.cookies["trilium-device"] === "mobile" ? "mobile" : "desktop";
|
||||||
|
|
||||||
const csrfToken = req.csrfToken();
|
const csrfToken = (typeof req.csrfToken === "function") ? req.csrfToken() : undefined;
|
||||||
log.info(`Generated CSRF token ${csrfToken} with secret ${res.getHeader("set-cookie")}`);
|
log.info(`Generated CSRF token ${csrfToken} with secret ${res.getHeader("set-cookie")}`);
|
||||||
|
|
||||||
// We force the page to not be cached since on mobile the CSRF token can be
|
// We force the page to not be cached since on mobile the CSRF token can be
|
||||||
|
Loading…
x
Reference in New Issue
Block a user