Skip to content

Build your personal knowledge base with Trilium Notes

fix: handle optional logout token

dajiaohuang0c77c0982173
diff --git a/apps/client/src/components/entrypoints.ts b/apps/client/src/components/entrypoints.ts
index 8803854cf9..8ce030a5e8 100644
--- a/apps/client/src/components/entrypoints.ts
+++ b/apps/client/src/components/entrypoints.ts
@@ -105,17 +105,19 @@ export default class Entrypoints extends Component {
const form = document.createElement("form");
form.method = "POST";
const httpBaseUrl = window.glob.httpBaseUrl;
- form.action = window.glob.isElectron
- ? new URL(`${window.glob.baseApiUrl}../logout`, window.location.href).href
- : httpBaseUrl
- ? new URL("/logout", httpBaseUrl).href
- : new URL(`${window.glob.baseApiUrl}../logout`, window.location.href).href;
+ if (window.glob.isElectron) {
+ form.action = String(new URL(`${window.glob.baseApiUrl}../logout`, window.location.href).href);
+ } else if (httpBaseUrl) {
+ form.action = String(new URL("/logout", httpBaseUrl).href);
+ } else {
+ form.action = String(new URL(`${window.glob.baseApiUrl}../logout`, window.location.href).href);
+ }
form.hidden = true;
const csrfToken = document.createElement("input");
csrfToken.type = "hidden";
csrfToken.name = "x-csrf-token";
- csrfToken.value = window.glob.csrfToken;
+ csrfToken.value = window.glob.csrfToken ?? "";
form.append(csrfToken);
document.body.append(form);