question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does the `site` option still exist?

See original GitHub issue

Your question I’m wondering if the site field in options exists such as is referenced in #423 ?

What are you trying to do I’m deploying on Vercel and am attempting to set NEXTAUTH_URL dynamically based on the current deployment URL. Vercel exposes (VERCEL_URL)[https://vercel.com/docs/build-step?query=environment#system-environment-variables] which holds the current deployment URL. I was going to pass this to the site option to dynamically set the redirect/callback URL based on the deployment.

I’m also trying to find if Vercel supports setting an env var to equal another, i.e. I could just do NEXTAUTH_URL=VERCEL_URL, but I haven’t found this yet.

Feedback Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.

  • Found the documentation helpful
  • Found documentation but was incomplete
  • Could not find relevant documentation
  • Found the example project helpful
  • Did not find the example project helpful

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
iaincollinscommented, Sep 22, 2020

Hi there!

The site and baseUrl options were removed in v3 and replaced with the NEXTAUTH_URL environment variable.

The primary reason for this was that, as pages and API routes run as isolated functions under Serverless, there wasn’t a practical way to share configuration for the canonical site URL between them and that the approach in v2 (of using secure cookie with a payload to handle basic URL configuration) didn’t work 100% of the time.

I’d wanted to avoid using an environment variable for something like this, but the only other option would be to split configuration off into a separate file and include it in both the front end and the back end. However, this would require MULTIPLE configuration files (as you wouldn’t want things like SECRET or CLIENT ID values leaking into the front end bundle) so wasn’t a great solution either.

Using an environment variable for this seems like the least worst option for now, as it’s available to ALL pages and API routes in an app automatically, even if it is a bit weird. I do have thoughts on how we might improve the developer experience in future, but I don’t see us ever breaking this option.

Note you can ad a custom path to this value e.g. NEXTAUTH_URL=https://ww.example.com is valid (with the default base ath of /api/auth) but you could also specify NEXTAUTH_URL=https://ww.example.com/custom-base-path/api/auth to use a custom base path for the API route.

The VERCEL_URL is a fallback but it’s not currently a great experience as it’s a random hostname for an instance rather than the canonical URL for a deployment. So, it might work well for email or a credentials provider, but you probably want to set it explicitly for OAuth, as typically URLs for callback URLs have to be very explicit (and can’t just be at a domain).

This is developer pain I’m also interested in easing in future releases! The Vercel team might also drop a solution to this at some point, which we can then take advantage of.

The one thing that confused me about the VERCEL_URL is that I had to go and set it explicitly for it to be populated - I wasn’t seeing it set by default, so still wasn’t ideal for tihings like Pull Request environments.

1reaction
JLHassoncommented, Sep 21, 2020

Oh interesting! That’s great to know, I just need to unset that variable on my other deployments 👌 thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Publish & share your site - Sites Help - Google Support
This option is only available if your site is set to "Public on the web," and can be viewed by anyone. On a...
Read more >
SEO 101: Why is My Website Not Showing in Google Search?
Penalized – When your domain or page still exists but none of your pages can be found through very direct search queries.
Read more >
Dial-Up Internet Providers Still Exist | Find Available Options
Yes, and with a phone line and the right equipment, you can likely get dial-up internet in your area. It's a great option...
Read more >
9 Reasons Your Website Isn't Showing Up On Google (and ...
1. Your website is too new ... It takes time for Google to discover new websites and web pages. If you only launched...
Read more >
Housing Choice Voucher Program Section 8 - HUD
Housing vouchers - how do they function? Down arrow The rent subsidy. Down arrow Can I move and continue to receive housing choice...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found