{"record":{"id":"a5703b5da36dd53d","repo":"toeverything/AFFiNE","slug":"invalid-server-externalurl-configured-it-must-b","errorCode":null,"errorMessage":"Invalid `server.externalUrl` configured. It must be a valid url.","messagePattern":"Invalid `server\\.externalUrl` configured\\. It must be a valid url\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/backend/server/src/base/helpers/url.ts","lineNumber":49,"sourceCode":"  redirectAllowHosts!: string[];\n\n  origin!: string;\n  allowedOrigins!: string[];\n  baseUrl!: string;\n\n  constructor(\n    private readonly config: Config,\n    private readonly cls?: ClsService\n  ) {\n    this.init();\n  }\n\n  @OnEvent('config.changed')\n  @OnEvent('config.init')\n  init() {\n    if (this.config.server.externalUrl) {\n      if (!this.verify(this.config.server.externalUrl)) {\n        throw new Error(\n          'Invalid `server.externalUrl` configured. It must be a valid url.'\n        );\n      }\n\n      const externalUrl = new URL(this.config.server.externalUrl);\n\n      this.origin = externalUrl.origin;\n      this.baseUrl =\n        externalUrl.origin + externalUrl.pathname.replace(/\\/$/, '');\n    } else {\n      this.origin = this.convertHostToOrigin(this.config.server.host);\n      this.baseUrl = this.origin + this.config.server.path;\n    }\n\n    this.redirectAllowHosts = [this.baseUrl];\n\n    this.allowedOrigins = [this.origin];\n    if (this.config.server.hosts.length > 0) {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/2af30773aecd567f09b346e7b72fc69143144057/packages/backend/server/src/base/helpers/url.ts#L31-L67","documentation":"UrlHelper.init validates server.externalUrl on config init/change and throws when the configured value does not parse as a valid URL, preventing the server from booting with a base URL that would produce broken links.","triggerScenarios":"Thrown at packages/backend/server/src/base/helpers/url.ts:53 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set server.externalUrl in the config (or AFFINE_SERVER_EXTERNAL_URL env) to a fully-qualified URL including protocol, e.g. https://affine.example.com.","Remove the externalUrl setting if you don't need absolute URLs in emails/redirects — the server will fall back to request-derived origins.","Validate the URL locally with new URL(value) before deploying the config."],"exampleFix":"# config.yaml\nserver:\n  externalUrl: 'https://affine.example.com' # must include scheme and host","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2af30773aecd567f09b346e7b72fc69143144057","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}