Skip to content

Calculate NEXTAUTH_URL based on incoming request #4514

@buehler

Description

@buehler

Description 📓

Setting the NEXTAUTH_URL environment variable seems unnecessary in certain environments. For example, when running a next app on google cloud run, the URL of the application is only available after the first deployment. Therefore, to create preview deployments, one needs to deploy an application twice. First, without the URL env, and after the url is available, a second time with the NEXTAUTH url var set.

As I'm aware of, other frameworks like ASP.Net do calculate the current host based on the incoming request. Would it be possible to do the same for next auth as well?

The calculation of ASP.net even works with proxies since the framework does respect X-Forwarded-For headers.

Then, one could remove the need of this variable altogether or just use it to overwrite the calculation for good.

How to reproduce ☕️

Create a nextjs app with next auth (let's say a google login), and try to deploy it on google cloud run.

Contributing 🙌🏽

No, I am afraid I cannot help regarding this

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions