Is it possible to disable client side routing in Gatsby?
I'm using Gatsby to generate a static site which only has one page and will be served from AWS/S3. I'm running into an issue caused by Gatsby removing the object suffix from the URL (https://s3.amazonaws.com/top-bucket/sub-bucket/index.html becomes https://s3.amazonaws.com/top-bucket/sub-bucket/) after the page and the Gatsby runtime loads. This issue does not happen if I disable JavaScript, so I'm pretty certain it's caused by Gatsby's use of React/Reach Router.
Is there any way to disable this behavior? I know I can probably setup a redirect on S3 to handle the request to the bucket, but I'd prefer to do this at the application level, if possible.
This is a hack and may not work in anyone else's application or break with future releases of Gatsby, but I was able to prevent this redirect by setting window.page.path = window.location.pathname;
in gatsby-browser.js. This short circuits a conditional check in production-app.js, which attempts to "make the canonical path match the actual path" and results in the (IMO) unexpected behavior referenced above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With