Reputation: 835
I have a web app (using Angular 2 with webpack) that should not require more than static file hosting...except that I am using html5 style routing (slashes rather than hashes). I would like to host it in an AWS S3 Bucket. If a user goes to the root of my app, the S3 Bucket serves index.html, and everything is fine. If the user clicks some button that uses the router to take them to myapp.com/routename, then it still works fine (because there's technically no page reload). But if the entry point for the user is myapp.com/routename, then the browser will do a get request to that url, and S3 will not know that index.html is the thing it should be responding with. I've tried using the S3 routing config...but the routing config seems to only be able to do redirects which actually change the url in the urlbar. For example, if I say redirect myapp.com/routename to myapp.com, it's not just serving index.html at that url too, it's actually changing the url in the browser, which sends the user back to the "/" route. Is there a way to configure and S3 bucket to do regular routing instead of redirects?
Upvotes: 0
Views: 639
Reputation: 9411
Theoretically you could copy your index.html to something like 404.html and enter this filename in "Error Document" section of S3 settings. When there is no page to display (error 404), S3 would show that document.
It should work, but it's a horrible idea. Browsers will still receive 404 HTTP code in HTTP headers.
Upvotes: 1