{"record":{"id":"c7f4a342eee9cf21","repo":"siyuan-note/siyuan","slug":"remote-only-accepts-an-origin-without-a-path-qu","errorCode":null,"errorMessage":"--remote only accepts an origin without a path, query, or fragment","messagePattern":"--remote only accepts an origin without a path, query, or fragment","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/electron/remoteKernel.js","lineNumber":22,"sourceCode":"const getArgFrom = (args, name) => {\n    const prefix = name + \"=\";\n    const arg = args.find((item) => item === name || item.startsWith(prefix));\n    if (!arg) {\n        return;\n    }\n    return arg === name ? \"\" : arg.slice(prefix.length);\n};\n\nconst normalizeRemoteKernelOrigin = (value) => {\n    if (!value) {\n        throw new Error(\"--remote requires a URL\");\n    }\n    const url = new URL(value);\n    if (url.username || url.password) {\n        throw new Error(\"--remote does not accept credentials in the URL\");\n    }\n    if (url.pathname !== \"/\" || url.search || url.hash || value.includes(\"?\") || value.includes(\"#\")) {\n        throw new Error(\"--remote only accepts an origin without a path, query, or fragment\");\n    }\n    if (url.protocol !== \"https:\") {\n        throw new Error(\"--remote requires HTTPS\");\n    }\n    return url.origin;\n};\n\nconst insecureCertificateSwitchNames = Object.freeze([\n    \"allow-insecure-localhost\",\n    \"ignore-certificate-errors\",\n    \"ignore-certificate-errors-spki-list\",\n    \"ignore-ssl-errors\",\n    \"ignore-ssl-errors-with-hosts\",\n]);\nconst insecureCertificateSwitches = new Set(insecureCertificateSwitchNames);\nconst unsafeRemoteChromiumSwitchNames = Object.freeze([\n    ...insecureCertificateSwitchNames,\n    \"allow-running-insecure-content\",","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/app/electron/remoteKernel.js#L4-L40","documentation":"normalizeRemoteKernelOrigin only accepts a bare origin. URLs containing a path, query string, or fragment are rejected so the app can deterministically append its own API and stage paths; anything after the host:port would break the constructed endpoints.","triggerScenarios":"A --remote value whose URL has pathname !== \"/\", or that contains \"?\" or \"#\" anywhere — e.g. https://host:6806/siyuan, https://host:6806/?x=1, or https://host:6806/#anchor.","commonSituations":"Pasting a full URL copied from a browser address bar including a path like /stage/build/app/; trailing path added by a shared link; query params added by SSO redirects; a stray # in a shell command due to unquoted input.","solutions":["Trim the URL down to protocol://host:port before passing it to --remote","If the kernel sits behind a subpath reverse proxy, expose a dedicated origin/subdomain for it instead","Quote the URL in your shell to prevent ?, # from being interpreted","Remove SSO/query parameters and complete any redirect login inside the app instead"],"exampleFix":"// before\n//   --remote \"https://myhost:6806/stage/build/app/\"\n// after\n//   --remote \"https://myhost:6806\"","handlingStrategy":"validation","validationCode":"const u = new URL(candidate);\nif (u.pathname !== \"/\" || u.search || u.hash || candidate.includes(\"?\") || candidate.includes(\"#\")) {\n  throw new Error(\"--remote accepts only protocol://host:port\");\n}","typeGuard":"const isBareOrigin = (v) => { try { const u = new URL(v); return u.pathname === \"/\" && !u.search && !u.hash; } catch { return false; } };","tryCatchPattern":"try {\n  const origin = normalizeRemoteKernelOrigin(args.remote);\n} catch (e) {\n  if (e.message.startsWith(\"--remote only accepts an origin\")) {\n    // auto-trim: use new URL(v).origin and retry\n  }\n}","preventionTips":["Copy only the scheme+host+port part of the URL","Expose subpath-proxied kernels on a dedicated origin/subdomain","Quote URLs in the shell so ?, # are not appended or misread"],"tags":["cli","url-validation","origin","remote-kernel"],"backgroundTag":"invalid-url-format","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}