erikringsmuth / app-router

Router for Web Components
https://erikringsmuth.github.io/app-router/
MIT License
610 stars 83 forks source link

Problems with mode="pushstate" #104

Closed ozasadnyy closed 9 years ago

ozasadnyy commented 9 years ago

Thanks for the project, but after I am clicking on link:

<a is="pushstate-anchor" href="/about" layout horizontal center>About</a>

I am redirecting to /about page that doesn't exist.

Should I include pushstate-anchor to make it work?

Router settings:

<app-router mode="pushstate" trailingSlash="ignore">
            <app-route path="/" import="/elements/home-page/home-page.html"></app-route>
            <app-route path="/about" import="/elements/about-page/about-page.html"></app-route>
            <app-route path="/schedule" import="/elements/schedule-page/schedule-page.html"></app-route>
</app-router>

I am using BrowserSync as a local server from

erikringsmuth commented 9 years ago

I'm not sure what's wrong without seeing the code. Is the server returning a 404? Are you importing the pushstate-anchor element? If you're using non-hash paths, the server needs to be able to return a page when the user goes directly to the page's URL.

ozasadnyy commented 9 years ago

Re: Are you importing the pushstate-anchor element? It was a question actually if should I include it or not, because I have found anything about it.

erikringsmuth commented 9 years ago

Yeah, you'll need to include it if you want it to use history.pushState() instead of loading a new page. That said, if you use pushState, your server needs to be able to return a page when you go to /about or you will get a 404. Hash URLs are simpler to deal with but regular URLs look better. That's the trade off.

ozasadnyy commented 9 years ago

So I can't use GitHub pages for this purpose?

erikringsmuth commented 9 years ago

Not with the pushstate-anchor. You'd need to use hash URLs for sites that only serve up static content.

ozasadnyy commented 9 years ago

ok, thanks a lot for your time!