#NEXTAUTH_URL - should be known while building?

12 messages · Page 1 of 1 (latest)

slim ingot
#

I'm building an app image that shouldn't depend on any URLs and instaed receive them in runtime. But I cannot build my app without setting a specific URL. How to fix this?

past citrusBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

gentle fox
#

@slim ingot can you explain your trouble a big more?

#

can't fully understand

slim ingot
#

Hi @gentle fox
Sure.
I have an app that uses next-auth.
When I run npm run build it fails at the info - Collecting page data... stage saying something like:

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:405:5)
    at new URL (node:internal/url:778:13)
    at parseUrl (/builds/<project>/node_modules/next-auth/utils/parse-url.js:17:16)
    ...

I was able to empirically track down what URL it's talking about. It's NEXTAUTH_URL
I want to have it undefined/empty while building, because it's different for prod/dev/stage

gentle fox
#

iirc, nextauth requires NEXTAUTH_URL in env or you should put fallback url somewhere else

slim ingot
#

Here they say: When deploying to production, set the NEXTAUTH_URL environment variable to the canonical URL of your site.
Deploying, not building. If it matters...

gentle fox
#

I want to have it undefined/empty while building, because it's different for prod/dev/stage

#

I don't understand this much - why is it?

slim ingot
#

Different auth backends, depending on where we deploy

#

not only auth, but site urls are different as well