ENV for Base URL has name mismatch in logs and an actual value #2803

Closed
opened 2026-03-13 10:21:13 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @cucumber-sp on GitHub (Feb 1, 2026).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Create a backend without setting BETTER_AUTH_URL.

In console you would receive message:

2026-02-01T11:58:08.244Z WARN [Better Auth]: [better-auth] Base URL could not be determined. Please set a valid base URL using the baseURL config option or the BETTER_AUTH_BASE_URL environment variable. Without this, callbacks and redirects may not work correctly.

Set BETTER_AUTH_BASE_URL and message is still here

Current vs. Expected behavior

Actual name for variable according to documentation is BETTER_AUTH_URL so console output should use it because provided name has no effect.

What version of Better Auth are you using?

1.4.18

System info

Not needed

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)


Additional context

No response

Originally created by @cucumber-sp on GitHub (Feb 1, 2026). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Create a backend without setting BETTER_AUTH_URL. In console you would receive message: ``` 2026-02-01T11:58:08.244Z WARN [Better Auth]: [better-auth] Base URL could not be determined. Please set a valid base URL using the baseURL config option or the BETTER_AUTH_BASE_URL environment variable. Without this, callbacks and redirects may not work correctly. ``` Set BETTER_AUTH_BASE_URL and message is still here ### Current vs. Expected behavior Actual name for variable according to documentation is BETTER_AUTH_URL so console output should use it because provided name has no effect. ### What version of Better Auth are you using? 1.4.18 ### System info ```bash Not needed ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
Author
Owner

@better-auth-agent[bot] commented on GitHub (Feb 1, 2026):

It seems like you've encountered a common issue with the environment variable names in Better Auth. From your description, it looks like you are using BETTER_AUTH_BASE_URL, but the warning message references BETTER_AUTH_URL. According to the documentation, the correct environment variable that Better Auth checks for the base URL is actually BETTER_AUTH_URL. If you set the BETTER_AUTH_URL environment variable, this should help resolve the warning message you are seeing in the logs.

From your case, make sure that you are setting BETTER_AUTH_URL instead of BETTER_AUTH_BASE_URL in your environment to align with the intended behavior of the application [1].

If you need further assistance or clarification, feel free to ask! Have you been able to test this change with your installation?

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Feb 1, 2026): It seems like you've encountered a common issue with the environment variable names in Better Auth. From your description, it looks like you are using `BETTER_AUTH_BASE_URL`, but the warning message references `BETTER_AUTH_URL`. According to the documentation, the correct environment variable that Better Auth checks for the base URL is actually `BETTER_AUTH_URL`. If you set the `BETTER_AUTH_URL` environment variable, this should help resolve the warning message you are seeing in the logs. From your case, make sure that you are setting `BETTER_AUTH_URL` instead of `BETTER_AUTH_BASE_URL` in your environment to align with the intended behavior of the application [[1]](https://www.better-auth.com/docs/reference/options). If you need further assistance or clarification, feel free to ask! Have you been able to test this change with your installation? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@dosubot[bot] commented on GitHub (Feb 1, 2026):

Hi @cucumber-sp! I'm Dosu and I’m helping the better-auth team.

The correct environment variable for setting the Base URL in Better Auth v1.4.18 is BETTER_AUTH_URL. The code does not use BETTER_AUTH_BASE_URL at all, so setting it has no effect. The warning message referencing BETTER_AUTH_BASE_URL is incorrect and should mention BETTER_AUTH_URL instead. To resolve the warning and configure your backend properly, set BETTER_AUTH_URL in your environment. Updating the log message to match the actual config option would prevent future confusion. You can see the relevant code logic here.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Feb 1, 2026): <!-- Greeting --> Hi @cucumber-sp! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> The correct environment variable for setting the Base URL in Better Auth v1.4.18 is `BETTER_AUTH_URL`. The code does not use `BETTER_AUTH_BASE_URL` at all, so setting it has no effect. The warning message referencing `BETTER_AUTH_BASE_URL` is incorrect and should mention `BETTER_AUTH_URL` instead. To resolve the warning and configure your backend properly, set `BETTER_AUTH_URL` in your environment. Updating the log message to match the actual config option would prevent future confusion. You can see the relevant code logic [here](https://github.com/better-auth/better-auth/blob/583f12fb7db38681ee882d219ce3895faa4a6976/packages/better-auth/src/utils/url.ts#L106-L158). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/1798bd49-7cc1-4609-b980-3414dc40f2a2?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/1798bd49-7cc1-4609-b980-3414dc40f2a2?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/1798bd49-7cc1-4609-b980-3414dc40f2a2?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/1798bd49-7cc1-4609-b980-3414dc40f2a2?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/1798bd49-7cc1-4609-b980-3414dc40f2a2?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/1798bd49-7cc1-4609-b980-3414dc40f2a2?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/1798bd49-7cc1-4609-b980-3414dc40f2a2?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20correct%20environment%20variable%20for%20setting%20the%20Base%20URL%20in%20Better%20Auth%20v1.4.18%20is%20%60BETTER_AUTH_URL%60.%20The%20code%20does%20not%20use%20%60BETTER_AUTH_BASE_URL%60%20at%20all%2C%20so%20setting%20it%20has%20no%20effect.%20The%20warning%20message%20referencing%20%60BETTER_AUTH_BASE_URL%60%20is%20incorrect%20and%20should%20mention%20%60BETTER_AUTH_URL%60%20instead.%20To%20resolve%20the%20warning%20and%20configure%20your%20backend%20properly%2C%20set%20%60BETTER_AUTH_URL%60%20in%20your%20environment.%20Updating%20the%20log%20message%20to%20match%20the%20actual%20config%20option%20would%20prevent%20future%20confusion.%20You%20can%20see%20the%20relevant%20code%20logic%20%5Bhere%5D%28https%3A//github.com/better-auth/better-auth/blob/583f12fb7db38681ee882d219ce3895faa4a6976/packages/better-auth/src/utils/url.ts%23L106-L158%29.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/7748)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2803