-
Notifications
You must be signed in to change notification settings - Fork 116
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
Always redirecting to .index.html ? #59
Comments
Update - |
I am having the same issue. |
I'm running into the same issue with a gatsby.js app and gatsby. The routing is great initially, but when I refresh my page, I get redirected to index.html and nothing loads. My redirects in the amplify profile looks like this:
What am I missing?
|
Oh I got it! You need a |
@CaptainChemist Still getting redirected to |
@ilyador I just realized that I'm getting the same behavior as you. What tricked me is that although I did fix the problem where I refresh my page and I get redirected to an index.html page that is blank, the consequence of creating the 404 Rewrite rule is that I do get redirected to index.html for non-root pages which messes up the google metatags and any SEO that I'd want for that page. Such a bummer- it was so close! |
This worked for me, I was able to navigate without any refresh problems. |
@IsaacTrevino watch out- as I mentioned in a later post, you might run into problems if you submit that particular link to the facebook share debugger so it is worth checking that crawlers can properly index the page when you use the 404 Rewrite even though the page appears to load fine when manually going to the page. This might only be an issue with Gatsby but if you notice, that you get a 206 error it might also be worth waiting 24 hours and checking again because I've noticed that there is a caching issue with amplify that seems to resolve itself if you wait 24hr. |
Does somebody know if you can update the routing through the amplify cli? |
@CaptainChemist were you able to get the 404 rewrite to not redirect to |
Hi @CaptainChemist @ilyador, please see this page in the docs Under "Redirects for Single Page Web Apps (SPA)" for an example of a 200 rewrite to allow your client side router to handle direct navigation to urls. Please let us know if this helps resolve your issue. @tomasyaya while you currently cannot update redirects using the amplify cli, you can do so using the aws cli (update-app) (create-app) with the |
So I am using
To that effect. |
I'm having a similar issue to this bug report. I'm using ReactJS and react-router-dom. I can navigate to various pages of my site by clicking on links that are in the body of the page. However, if I navigate directly (using the address bar of the browser) or by clicking on links in my Nav menu, I get redirected to /index.html. The body-links and the nav-links look identical in terms of their hrefs when I Inspect Element on them. Also, none of the redirects happen in the localhost version of the site, just in the Amplify-deployed version. |
I found the Redirects settings and removed the one that Amplify had added on its own, redirecting <*> to /index.html. However, deleting this setting just made it so that the links that were exhibiting strange behavior before now lead to a "This XML file does not appear to have any style information ..." error page. (I didn't know I was using any XML at all.) |
@MEBonham did you follow this #59 (comment) |
I wasn't sure what parts of it were applicable, but I'll experiment with it. EDIT: The first rule there seems to have fixed the problem for now. Thanks for answering! |
how can i serve my next.js based app with amplify? After passing all the steps, the page is redirecting to index.html page and nothing is shown. |
@vishalvishalgupta we currently do not support server rendered apps. See: #412 and upvote. |
@CaptainChemist were you able to find the solution to get it to work with metatags and SEO? |
@grigull I think there is some issue the redirects when hosted on amplify. With that said, I was able to get around it by having all of my login and redirects under a /user/* namespace instead of the root /. I use the /<*> source address, /index.html target address and 404 (redirect). |
Hi, how can I change Rewrites and Redirects in amplify console? |
For people googling this and ending up here, the rewrite solution above (while not great for SEO) will work. Add a rule in Amplify page for your site, Rewrites and Redirects. Then, in the head section of index.html, add this: After that you'll be able to direct link. |
had the same issue when refreshing a page called "profil" path
|
how do i fix the metatags issue due to the redirect ? I have the below configuration in amplify |
You just save me at least one hour of debugging why it happing, thank you !!! |
Had to remove the last rule which seems to have fixed my issue https://www.narenvadapalli.com/blog/gatsby-site-redirecting-to-homepage-aws-amplify/ |
Surprisingly, no one has mentioned the sort order here, the request is always redirected to index.html because the default one is matched due to its sort order. Your custom route should have a higher priority than the default one. In amplify click on edit and use 'Order' arrow navigation to manage the priority. |
@CaptainChemist , would this solution have a negative impact on SEO? |
this helped re: my use case as well |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
** Please describe which feature you have a question about? **
So I've got a basic ReactJS project running on amplify.
Using the "react-router-dom" I'm able to link to urls such as
/
/docs/
/docs/food/
/docs/activities/
/settings/
How can I set this up using Amplify? Currently it is always redirecting me to /index.html if I refresh the page.
The text was updated successfully, but these errors were encountered: