-
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
Deploying Gatsby breaks routing and the gatsby-node and gatsby-browser setup #991
Comments
Just to clarify, did you deploy your project through the Amplify Console? |
@UnleashedMind Yes, I did |
@ilyador can you add the following redirect rule: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa |
I already tried that and it didn't help. |
@ilyador I'm keeping one open issue as you filed two issues with the same problem. This issue is still open and we'll investigate it. Any way you can provide us with a sample repo to help with reproducing your scenario? |
@ilyador I am running a few gatsby projects on amplify, havent come across a similar issue though. I have plenty of stuff going on in my |
I'm having a similar issue - I've deployed a gatsby site for a client to Amplify through the Amplify Console and followed this https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa. These are my current rules:
I cannot refresh a page or navigate directly (via browser address bar) to any link other than the root. Without any deep linking I am concerned that our SEO efforts are impacted negatively. Creating a build locally and serving it ( What I find strange is that even when I remove all redirects the behaviour persists. I tried some suggestions referenced here #59 (comment) but have had no luck - keeping an eye out here:https://github.com/aws-amplify/amplify-console/issues?q=is%3Aissue+is%3Aopen+redirect to try and find a solution to this. Have you made any progress in investigating this original issue above? Any help would be greatly appreciated. |
Here is an example repo to better illustrate the behaviour explained in #991 (comment): https://github.com/chriswolmarans/gatsby-starter-mobx-react-hooks-context-api Deployed to Amplify via console here:
Compare to behaviour here:
|
@chriswolmarans I checked the codesandbox, seems like you have static routes at For client only routes, check the gatsby documentation here. I have always found the amplify URL rewrite functionality to work with these Gatsby requirements. If you can share the rewite/redirect rules for the app at |
Thank you @soumik-mukherjee, here are the rewrite/redirect rules for the app at https://master.d1f0rl59yms54k.amplifyapp.com/:
The app behaves as intended now after removing the above rules and changing them to:
After applying the same steps to the main site (not the example repo) it took some time for the change to take effect, which initially appeared as if it isn't working at all. After a few minutes it worked, I guess I just had to wait longer to see the changes initially. Thank you very much for the help @soumik-mukherjee, appreciate it. |
I think the amplify web hosting is backed by a cdn, and I would assume the rewrite rules also stay on the edge service. While amplify will manage invalidating objects intelligently for you, you should expect a delay when you change things. |
Hey, I have the same issues. I temporarily resolve this issue by removing all existing rules and changed my URL from |
Same issues |
1 similar comment
Same issues |
In my case I have removed all the rules |
I was having the same issue with any path other than |
I had the same issue with my Gatsby site on Amplify on removed all rewrite and redirect rules. The only that now exists is to redirect the non-www domain to the www domain:
|
Resolving due to age - please re-open if you are still experiencing issues. |
Wanted to add a note - @chriswolmarans solution worked for me. Using the console I simply removed the </^[^.]+$|.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/> rule and changed the /<*> rule to target /404/index.html with type 404 (Redirect) and now I can send users directly to routes and refreshing doesn't take me to the root anymore. Thanks @chriswolmarans ! |
For me to get client side routing to work, I had to do:
Note that the Gatsby docs tell you |
I've been struggling with redirects and images not loading for about a week and this ^^^ fixed both issues. Just wanted this right at the bottom for anyone else coming here for input. |
@chriswolmarans your solution works, but every page gets served with a 404 response. The correct content still loads and everything looks like it's working fine, but having the wrong HTTP status code is obviously still a massive problem. Are you getting the same? |
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. |
Locally my gatsby site works fine, however deploying it to Amplify breaks the following:
gatsby-browser.js
is being ignored. Seems like it is not being called at all.gatsby-node.js
and seems like this is connected to the routing problem: client-side routes don't work too.The text was updated successfully, but these errors were encountered: