Closed ochowie closed 8 years ago
SPAs (Single Page Applications) that use HTML5 History won't work with a simple HTTP server after a refresh. I'm no server expert, but here's a quick explanation:
When you are at /
, the server knows that it should load /index.html
. But when you navigate to, say, /foo
and refresh, the server will look for /foo/index.html
and it won't find it, because the only HTML file you do have is /index.html
, the views are generated dynamically.
You need to redirect all requests to /index.html
, like this example does here. Then when you go to /foo
, the server will load /index.html
and by reading the URL it will figure out which view to load.
If you really want to use the simple HTTP server, you can always switch to createHashHistory
.
I can confirm that changing to hash history works.
When running the basic example it is not possible to refresh the page when not on the top level route. I get the following error:
Error response
Error code 404.
Message: File not found.
Error code explanation: 404 = Nothing matches the given URI.
This doesn't happen when the route is at '/'.
I am executing the basic example using python's SimpleHTTPServer.