Set the Location header on redirected responses #2364

Closed
opened 2026-03-13 09:47:23 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @benmccann on GitHub (Nov 22, 2025).

Is this suited for github?

  • Yes, this is suited for github

You cannot use the response returned by better-auth when there is a redirect and need to manually modify it before it is usable

Describe the solution you'd like

Set the standard Location header instead of setting the proprietary fields response.response.redirect and response.response.url

Describe alternatives you've considered

Continue to write extra code that would not be necessary if the Location header were set:

	if (response.response.redirect && response.response.url) {
		setHeaders({ Location: response.response.url });
	}

Additional context

No response

Originally created by @benmccann on GitHub (Nov 22, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. You cannot use the response returned by `better-auth` when there is a redirect and need to manually modify it before it is usable ### Describe the solution you'd like Set the standard `Location` header instead of setting the proprietary fields `response.response.redirect` and `response.response.url` ### Describe alternatives you've considered Continue to write extra code that would not be necessary if the `Location` header were set: ``` if (response.response.redirect && response.response.url) { setHeaders({ Location: response.response.url }); } ``` ### Additional context _No response_
GiteaMirror added the enhancement label 2026-03-13 09:47:23 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 22, 2025):

Thanks for opening this issue! We understand that needing to manually transfer the redirect URL into a standard Location header is inconvenient. Our team is already evaluating a change so that redirected responses include the standard Location header directly, which would eliminate the extra code you’re currently writing. In the meantime, using your workaround is a solid temporary solution. Could you share a bit more about your use case so we can better prioritize the fix? Tag @better-auth-agent if you would like an answer from the Agent.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Nov 22, 2025): Thanks for opening this issue! We understand that needing to manually transfer the redirect URL into a standard Location header is inconvenient. Our team is already evaluating a change so that redirected responses include the standard Location header directly, which would eliminate the extra code you’re currently writing. In the meantime, using your workaround is a solid temporary solution. Could you share a bit more about your use case so we can better prioritize the fix? Tag @better-auth-agent if you would like an answer from the Agent. <!-- 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

@GautamBytes commented on GitHub (Nov 23, 2025):

will be working on this!

@GautamBytes commented on GitHub (Nov 23, 2025): will be working on this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2364