Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refreshing a route while logged in redirects to index.html #27

Open
CaptainChemist opened this issue Jan 24, 2020 · 4 comments
Open

Refreshing a route while logged in redirects to index.html #27

CaptainChemist opened this issue Jan 24, 2020 · 4 comments

Comments

@CaptainChemist
Copy link

CaptainChemist commented Jan 24, 2020

I'm running into an issue with redirects when I deploy this app. The issue is that when I am logged in and reload the page, I get redirected to index.html which then redirects me to the home page. The expected behavior is that reloading the page should maintain the current route.

Steps to reproduce:

  1. Log in
  2. go to /app/home
  3. Reload the page
  4. App redirects user to / route which forces the user to have to navigate back to the /app/home to get where they were.

I made a video which documents this behavior:
https://www.youtube.com/watch?v=3rhpsWgAX3s

I played around with this and the behavior can be "fixed" by changing the 404 redirect to a 404 rewrite, but it has the negative consequence that none of the meta tags load and it shows up to facebook link debugger as a 404 error (in contrast to the default behavior where it all loads correctly). So that's to say that the 404 rewrite change probably isn't a long term solution.

Any ideas how you'd go about fixing this? Thanks so much for contributing this demo repo Nader, it's really great!

@devnantes44
Copy link

I've got a similar problem although with a slight difference:

  1. Log in
  2. go to /app/home
  3. Reload the page
  4. App redirects user to / route then redirec to /app/home

I followed this documentation: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa

Were you able to handle this issue @CaptainChemist ?

@CaptainChemist
Copy link
Author

@devnantes44 No, I wasn't able to solve it unfortunately.

@mtliendo
Copy link

@devnantes44 @CaptainChemist have you both had a chance to go through the above link and if so, is the issue still happening?

@CaptainChemist
Copy link
Author

CaptainChemist commented Mar 27, 2020

@mtliendo I just tried having the following be my only redirect and I can confirm that this did not fix my problem and in fact made it worse. So that documentation provided did not work in my case unfortunately.

source address: </^[^.]+$|.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>
target address: /index.html
type: 200

Previously, I could directly navigate to pages that was not a protected route and I would not be navigated to the home page, it was only protected pages that would get navigated back to the home page regardless of whether the person was logged in or not. I think for me personally, even though the expected behavior should be that I can see pages that I should be able to see even if I refresh the page without a redirect to the home page, as long as my public pages act like they should, I can work around that.

source address: /<*>
target address: /index.html
type: 404 (Redirect)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants