{"record":{"id":"e3b22af5543bda89","repo":"anomalyco/sst","slug":"function-url-is-not-enabled-enable-it-with-url","errorCode":null,"errorMessage":"Function URL is not enabled. Enable it with \"url: true\".","messagePattern":"Function URL is not enabled\\. Enable it with \"url: true\"\\.","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/function.ts","lineNumber":2972,"sourceCode":"      function: this.function,\n      /**\n       * The CloudWatch Log Group the function logs are stored.\n       */\n      logGroup: this.logGroup,\n      /**\n       * The Function Event Invoke Config resource if retries are configured.\n       */\n      eventInvokeConfig: this.eventInvokeConfig,\n    };\n  }\n\n  /**\n   * The Lambda function URL if `url` is enabled.\n   */\n  public get url() {\n    return this.urlEndpoint.apply((url) => {\n      if (!url) {\n        throw new VisibleError(\n          `Function URL is not enabled. Enable it with \"url: true\".`,\n        );\n      }\n      return url;\n    });\n  }\n\n  /**\n   * The name of the Lambda function.\n   */\n  public get name() {\n    return this.function.name;\n  }\n\n  /**\n   * The ARN of the Lambda function.\n   */\n  public get arn() {","sourceCodeStart":2954,"sourceCodeEnd":2990,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/function.ts#L2954-L2990","documentation":"The Function's `url` getter returns the Lambda function URL only when the `url` option was enabled at deploy time. Accessing .url on a function without url: true unwraps an undefined endpoint and throws this VisibleError instead of returning a broken value.","triggerScenarios":"Reading fn.url in sst.config.ts or in the output of a stack where the Function was created without url: true (or url: { ... } disabled); accessing url before/without a successful deploy.","commonSituations":"Linking a function and using its URL in an API route or frontend while forgetting to enable url; toggling url: false temporarily and downstream code still reading .url.","solutions":["Set url: true (or url: { authorizer: \"iam\" } etc.) on the Function args","If the URL should be conditional, guard with the underlying output instead of accessing .url directly"],"exampleFix":"// before\nconst fn = new sst.aws.Function(\"Fn\", {});\nconst endpoint = fn.url;\n// after\nconst fn = new sst.aws.Function(\"Fn\", { url: true });\nconst endpoint = fn.url;","handlingStrategy":"try-catch","validationCode":"const url = fn.urlEndpoint;\n// check the raw output before using .url\nurl.apply(u => { if (!u) console.warn(\"Function URL not enabled; set url: true\"); });","typeGuard":null,"tryCatchPattern":"try {\n  const endpoint = fn.url;\n  console.log(endpoint);\n} catch (e) {\n  if ((e as Error).message.includes(\"Function URL is not enabled\")) {\n    console.error(\"Set url: true on the Function\");\n  }\n  throw e;\n}","preventionTips":["Always set url: true on any function whose URL you consume","Access fn.urlEndpoint for conditional handling instead of fn.url when url may be off"],"tags":["aws","lambda","function-url","missing-config"],"backgroundTag":"url-not-enabled","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}