Invalid State Error on Safari iPhone iOS with Auth0 and React Vite

I’m developing a React application using Vite and I’m encountering an “invalid state” error exclusively on Safari on iPhone iOS when using Auth0 for authentication. The issue arises specifically when I include a returnTo property in the appState within the loginWithRedirect method. This problem does not occur on other browsers where the login flow with the returnTo redirect works properly.

Here are the relevant details of my project setup:

  • React version: 18.2.0
  • Vite version: 4.4.9
  • Auth0 React SDK version: 2.0.0
  • Running on Node.js 18.13.0 and NPM 9.7.2

I have already tried updating the packages and configurations, but the issue persists only on Safari on iOS. This behavior suggests a platform-specific issue that might be related to how Safari handles cookies, sessions, or redirects, differing significantly from other browsers.

Could anyone provide insights or share experiences on resolving similar issues with Auth0 on iOS? Any advice on specific configurations for Auth0 or Safari that could mitigate this problem would be greatly appreciated.