{"record":{"id":"30508392c27a770b","repo":"nextauthjs/next-auth","slug":"redirectproxyurl-must-be-a-valid-url-received","errorCode":null,"errorMessage":"redirectProxyUrl must be a valid URL. Received: ${provider.redirectProxyUrl}","messagePattern":"redirectProxyUrl must be a valid URL\\. Received: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/lib/init.ts","lineNumber":82,"sourceCode":"}: InitParams): Promise<{\n  options: InternalOptions\n  cookies: cookie.Cookie[]\n}> {\n  const logger = setLogger(config)\n  const { providers, provider } = parseProviders({ url, providerId, config })\n\n  const maxAge = 30 * 24 * 60 * 60 // Sessions expire after 30 days of being idle by default\n\n  let isOnRedirectProxy = false\n  if (\n    (provider?.type === \"oauth\" || provider?.type === \"oidc\") &&\n    provider.redirectProxyUrl\n  ) {\n    try {\n      isOnRedirectProxy =\n        new URL(provider.redirectProxyUrl).origin === url.origin\n    } catch {\n      throw new TypeError(\n        `redirectProxyUrl must be a valid URL. Received: ${provider.redirectProxyUrl}`\n      )\n    }\n  }\n\n  // User provided options are overridden by other options,\n  // except for the options with special handling above\n  const options: InternalOptions = {\n    debug: false,\n    pages: {},\n    theme: {\n      colorScheme: \"auto\",\n      logo: \"\",\n      brandColor: \"\",\n      buttonText: \"\",\n    },\n    // Custom options override defaults\n    ...config,","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/core/src/lib/init.ts#L64-L100","documentation":"init validates each provider's redirectProxyUrl by constructing a URL from it; if it is not a parseable absolute URL, a TypeError is thrown. redirectProxyUrl is used to detect whether the current host is acting as a redirect proxy for provider callbacks.","triggerScenarios":"Setting provider.redirectProxyUrl (or the top-level redirectProxyUrl passed through to the provider) to a relative path like \"/api/auth\", an empty string, a value with spaces/typos, or an environment variable that is undefined and interpolated as the literal \"undefined\".","commonSituations":"Missing or misnamed env var (e.g. AUTH_REDIRECT_PROXY_URL unset) interpolated into config; using a relative URL instead of an absolute one; deployment-specific base URLs not configured in preview environments.","solutions":["Set redirectProxyUrl to a complete absolute URL including scheme and host, e.g. https://example.com/api/auth/callback","Verify the env variable is defined in the deployment environment and referenced with the correct name","Remove redirectProxyUrl entirely if you are not using the redirect proxy feature"],"exampleFix":"// before\nredirectProxyUrl: process.env.AUTH_REDIRECT_PROXY // undefined -> \"undefined\"\n// after\nredirectProxyUrl: process.env.AUTH_REDIRECT_PROXY_URL ?? \"https://example.com/api/auth/callback\"","handlingStrategy":"validation","validationCode":"if (provider.redirectProxyUrl) { try { new URL(provider.redirectProxyUrl) } catch { throw new Error(`redirectProxyUrl must be absolute: got ${JSON.stringify(provider.redirectProxyUrl)}`) } }","typeGuard":"function isAbsoluteUrl(v: unknown): v is string { if (typeof v !== \"string\") return false; try { new URL(v); return true; } catch { return false; } }","tryCatchPattern":"try { return init(config) } catch (e) { if (e instanceof TypeError && e.message.includes(\"redirectProxyUrl\")) { console.error(\"Check AUTH_REDIRECT_PROXY_URL is set to an absolute URL\"); } throw e; }","preventionTips":["Validate env vars at startup with a schema library (zod/envsafe)","Always use absolute URLs with scheme and host for proxy settings","Provide sane defaults per environment instead of interpolating possibly-undefined values"],"tags":["config","invalid-url","redirect-proxy"],"backgroundTag":"invalid-url-config","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}