Dwight
Dwight

Reputation: 72

Redirect on safari (older iphone) doesn't work

I have issue that occurs in Safari on iPhones 11, 12, 13 and SE. This issue does not seem to be occurring on any iPhone 14 or 15. My app is structured like this:

auth.example.com
user.example.com
admin.example.com

After you login on auth.example.com, you are redirected to either user.example.com or admin.example.com. This works normally if you open the single tab, however, if you have user.example.com or admin.example.com already opened in tabs, and try to open auth.example.com and login, server responds normally, but redirect never happens.

After testing, it does appear that redirect happened "in the background", but never shown/redirected. I know this because if I open index.html of user.example.com and console.log anything, log shows in the console, but it still shows auth screen. Code I currently use to redirect is:

if(config.userUrl.includes(url)){
  Cookie.set("user", JSON.stringify(data), {
    domain,
    secure,
    sameSite,
  });
  window.location.replace(url);
}

I tried:

setTimeout(() => window.location.replace(url), 200)
window.location.href = url
window.open(url, "_self")

Do you have any suggestions on how can I fix this?

Additional information: I am using React for frontend, and node for the backend. Login system is swedish bankid. Also, this issue only appears on safari. Tested on Firefox, Chrome and Safari. Did not test Opera or any other browser.

Upvotes: 1

Views: 72

Answers (0)

Related Questions