Expo web AuthSession error: TypeError: Cannot read property 'startsWith' of undefined

Expo web AuthSession error: TypeError: Cannot read property 'startsWith' of undefined

我正在使用 AuthSession in my React Native Expo app to login with auth0 (following this example).

async mobileLogin(){
    const redirectUrl = AuthSession.getRedirectUrl();
    ...
}

登录在 Android 和 iOS 下工作正常,当我在 Web 上使用它时,AuthSession 模块中断:

bundle.js:19465 Uncaught (in promise) TypeError: Cannot read property 'startsWith' of undefined

深入研究 AuthSession Expo 模块,代码在第 150 行中断 (link to source code on github)。 在 expo documentation AuthSession should be supported for Web, but for one of its dependencies expo-app-auth:

Web support is planned to be added

我的猜测是,由于 Web 不支持 expo-app-auth,因此 AuthSession 在从 Web 使用时会中断(而在移动设备上使用)。这是真的?我是否应该在我的 React Native 应用程序中寻找另一种使用 auth0 从 Web 登录的方法?有什么建议吗?

很抱歉地通知您,AuthSession 实际上不适用于网络。 Check the doc page again 在 "Platform Compatibility" 下。

目前,你最好的选择是AppAuth. It's currently being ported to the web,所以我建议你留意它。