I'm experiencing a weird issue when trying to acce...
# prisma-whats-new
a
I'm experiencing a weird issue when trying to access my staging application deployed on heroku, from mobile. I have
/
and
/authenticate
- if the user tries to access
/
without being authenticated, they will be redirected to
/authenticate
this works from Chrome on my mac and in iOS. However, I can't access
/authenticate
directly from iOS, then I get a 404, while it still works fine in Chrome.
Okay so it's not an iOS specific thing, it is a Safari issue, the same is happening on Safari on Mac.
a
Do you happen to have masked domain forwarding active?
There is an issue with Safari and session cookies in that case. But I don't know the fine details...
a
I'm not doing any domain forwarding, only using heroku generated domains so far. This is my App.js and routes.js where the auth check and redirect happens:
App.js
Copy code
class App extends Component {
  _isLoggedIn = () => {
    return localStorage.getItem(GC_AUTH_TOKEN);
  }

  render() {
    const Routes = props => (
      this._isLoggedIn() ?
      <AuthenticatedRoutes userdata={this.props.data.user} /> :
      <NotAuthenticatedRoutes />
    );

    if (this.props.data.loading) {
      return (
        <Loading />
      );
    }

    return(
      <Routes />
    );
  }
  
}
routes.js
Copy code
export const AuthenticatedRoutes = () => (
  <div>
    <Switch>
      <Route exact path='/' component={Header} />
      <Route path='/createhandler' component={CreateHandlerPage} />
      <Route path='/newoperator' component={() => <h1>NewOperatorPage</h1>}/>
      <Route path='/:operatorslug' component={() => <h1>OperatorPage</h1>}/>
      <Route render={() => <h1>Page not found</h1>}/>
    </Switch>
  </div>
);

export const NotAuthenticatedRoutes = () => (
  <div>
    <Switch>
      <Route path='/authenticate' component={AuthenticatePage} />
      <Redirect to='/authenticate' />
    </Switch>
  </div>
);
a
Not using private browsing I assume?
a
Nope 🙂
🤔 1
a
Can you try the HashRouter instead of the BrowserRouter, just to see if that makes a difference?
a
Will try that now 😊
Okay, so that worked! Now the /#/ is added before the path however.
a
Yes, I know, but now at least you have narrowed down the problem
a
Thanks a lot!
a
I think you might be dealing with this: https://stackoverflow.com/a/42866874
Here's a link to the buildpack for Heroku, that also explains this: https://github.com/mars/create-react-app-buildpack#routing-clean-urls
The reason why that works on Chrome is that the serviceworker kicks in and takes care of this, but it doesn't on Safari...
a
Hmm will test that one out then!
There we go! Fantastic it works 🙏 thanks again!
😎 1
And I should say it works after changing back to BrowserRouter 🙂
a
I assumed you did 🙂 Great!