page.js
page.js copied to clipboard
Manually changing the URL causes 404 when using Hasbang=true mode
To reproduce:
- Run the examples project "Basic"
- Click the "Contact Me" URL
- You will now have "/basic/#!/contact/me" as the URL path
- Now, manually remove the "/me" from the address bar's URL. Press enter to load the URL
Current Result:
- Nothing happens
- Press enter again in the address bar and the page loads properly
Expected Result:
- /basic/#!/contact should load the corresponding page on first attempt.
If you add a catch all to the Basic example:
/* CATCH ALL */
page('*', function (argument, next) {
console.log("404", argument, next);
});
you will find the "404" page is triggered upon the first attempt to change the URL address manually.
I'm running into the same issue. When I'm browsing posts in my app, the URLs look like this: http://localhost:3000/#!/post/id But I get 404 when I enter such an URL manually.
How can this be fixed?
This has to work. Users often copy/paste URLs!
This also happens to me. When I am using live reload or any other thing to reload while I am developing. After each save page is reloaded but I get 404
@gokhandemirhan and @Boscop , please read the new section "Server Configuration". There are instructions that also serve for "live reloaders".
Everything based in nodejs, including live reloaders, can benefit from "history-api-fallback" to avoid 404 when reloading URL's.
I'm not using nodejs and I'm not talking about livereload. I mean when the user in the browser pastes that URL and hits Enter, they get 404, how to fix that?
@Boscop, what webserver you are using? If it is Apache or Nginx, there are instructions for them as well in the new section I mentioned.
The request isn't even sent to the server, the 404 happens in the client-side routing in page.js..