visionmedia / page.js

Micro client-side router inspired by the Express router
http://visionmedia.github.com/page.js
7.68k stars 689 forks source link

Manually changing the URL causes 404 when using Hasbang=true mode #292

Open sshadmand opened 9 years ago

sshadmand commented 9 years ago
To reproduce:

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.

Boscop commented 7 years ago

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!

gokhandemirhan commented 6 years ago

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

paulocoghi commented 6 years ago

@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.

Boscop commented 6 years ago

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?

paulocoghi commented 6 years ago

@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.

Boscop commented 6 years ago

The request isn't even sent to the server, the 404 happens in the client-side routing in page.js..