menu

ZEIT

Our mission is to make cloud computing as easy and accessible as mobile computing. You can find our Next.js community here.

Channels
Team

What's the "magic" behind zeit.co GitHub login without page loads?

February 21, 2020 at 10:29pm
The ZEIT community has a new home. This thread is preserved for historical purposes. The content of this conversation may be innaccurrate or out of date. Go to new community home →

What's the "magic" behind zeit.co GitHub login without page loads?

February 21, 2020 at 10:29pm
Hey there, when using logout/login on zeit.co with my GitHub account, I notice that I never endup on GitHub.com if I already accepted it once. It seems you implemented async oAuth login and this is unusual, can you share some details like how do you handle it/detect the first time the user logs in to GitHub versus other times? Thanks!

February 23, 2020 at 10:53pm
I think we did end up on GitHub (redirected from https://zeit.co/api/now/registration/login-with-github?mode=login&next=https%3A%2F%2Fzeit.co%2Flogin%3Fnext%3D%252Fdashboard. If there is no additional scopes requested, I believe GitHub will route us back to the redirect_uri without showing the consent screen.
  • reply
  • like

February 24, 2020 at 8:40pm
ok and you also couple this with the oauth login being a xhr/fetch request instead of a pageload (which is usually what's implemented). since the page is not reloaded at all
  • reply
  • like
ok and you also couple this with the oauth login being a xhr/fetch request instead of a pageload (which is usually what's implemented). since the page is not reloaded at all
it could have been a fetch + follow redirect. I saw the requests in dev tool got cleared out in the process so I assumed a page load. Either way, we can still agree that Zeit UX is nice on that part :)
  • reply
  • like
there's something else missing , a normal oauth flow does a pageload but here it does not it seems!
  • reply
  • like
there's something else missing , a normal oauth flow does a pageload but here it does not it seems!
I might be wrong but there is. The browser do not try to load the page and show it to you if it finds a 3xx headers. Furthermore, I doubt that Github would allow CORs for fetch to work. The page did unload to redirect. Perhaps try this with devtool before you click Continue with Github:
window.addEventListener("beforeunload", function() { debugger; }, false)
I guess Zeit is so optimized we do not even notice the page load 🤯.
  • reply
  • like
You're definitely right , it's just the normal behavior
  • reply
  • like
It's not even zeit or next.js, it just works: https://twitter.com/vvoyer/status/1232048105765425152
like-fill
1
  • reply
  • like