Currently using Amazon S3 and redirecting from 404s to /#/routename
but the HistoryLocation setup doesn't recognise the routes and starts up the defaultRoute every time.
e.g.
/profile
-> reload page -> server hits 404 -> server redirects to /#/profile
-> react router redirects to /default
.
I've read that we should be using RewriteRule style setups on the server but this is seemingly not possible with an Amazon S3 box.
So it would be nice if HistoryLocation could see a match of /#/route
and load up /route
. I thought this was how it should work so surprised it's not doing.
Haven't used Amazon S3 yet, but this whole 404 and server-side hash redirection situation (didn't even know that was possible) seems a little weird to me :smile:
Anyway, I don't think the router should handle this (at least not by default), since you might want to use the hash for other things when not using HashLocation.
I think you could easily solve this yourself with
// before Router.run
HistoryLocation.replace(HashLocation.getCurrentPath())
Thanks that works a charm :)
I've found cool way to overcome this with setting up Cloudfront. Basically you need to add custom behaviour for 404 error on cloudfront distribution. I've explained this in detail here
Most helpful comment
I've found cool way to overcome this with setting up Cloudfront. Basically you need to add custom behaviour for 404 error on cloudfront distribution. I've explained this in detail here