netlify-labs / react-netlify-identity

a tiny (4kb) React hook for using Netlify Identity, no UI. SEEKING MAINTAINERS
https://netlify-gotrue-in-react.netlify.com/
156 stars 25 forks source link

Using with Google Auth #29

Closed jdbence closed 4 years ago

jdbence commented 4 years ago

On Netlify, I have the Google identity enabled and using the default config. When I attempt to auth using loginProvider('google'), I can see the src does a redirect to the configured url ending in "/.netlify/identity/authorize?provider=google" The issue is it shows my app and not the Google auth screen. Any ideas what I'm missing?

I'm using a CRA and it looks like it's an issue when using the ServiceWorker. If I go into chrome and disable the ServiceWorker, I get to the Google Auth screen.

jdbence commented 4 years ago

In order to get this to work with a CRA, I had to create a custom workbox config and black list urls that start with /.netlify. CRA already checks for /_ so not sure if this lib can change from /.netlify to /_netlify or at-least make that configurable.

// Example of what currently is used to get this lib working as-is
navigateFallbackBlacklist: [
    new RegExp("^/.netlify"),
    new RegExp("^/_"),
    new RegExp("/[^/?]+\\.[^/]+$")
]

Firebase has something similar /__ but CRA works with it. https://firebase.google.com/docs/hosting/reserved-urls

ljosberinn commented 4 years ago

I've noticed that behaviour with CRA service worker too but hadn't investigated yet why this happens. Thanks for a temporary solution! Edit: heads up for anyone else: you'll need this package: https://github.com/liuderchi/sw-precache-cra and while @jdbence might have chosen another solution, sw-precache-cra requires navigateFallbackWhitelist, not ...Blacklist.

swyxio commented 4 years ago

thanks everyone.. netlify has to use the /.netlify/ namespace so i dont see that changing at all. whatever else we can do on the client or service worker side, we'll have to do that

Skagevang commented 4 years ago

navigateFallbackWhitelist with those RegExp will make all subdomains stop working offline. I can't seem to find a solution for making both things work?