routing - Polymer/web components <app-router> Cannot GET/<route> -
i'm using polymer app , using erik ringsmuth's app-router routing. code follows:
in index.html:
<app-router mode="pushstate"> <app-route path="/" import="/elements/login-page/login-page.html"></app-route> <app-route path="/dash" import="/elements/dash-page/dash-page.html"></app-route> <app-route path="/new" import="/elements/newapp-page/newapp-page.html"></app-route> <app-route path="*" import="/elements/dash-page/dash-page.html"></app-route> </app-router> in login-page.html:
<link rel="import" href="../../../bower_components/polymer/polymer.html"> <polymer-element name="login-page" attributes=""> <template> <link rel="stylesheet" href="login-page.css"> <section vertical layout center-center> <h1>login with:</h1> <fire-login provider="github"></fire-login> <fire-login provider="facebook"></fire-login> </section> </template> </polymer-element> the other pages similar. works fine out of box when refresh of pages cannot /dash or cannot /new. going root path , refreshing gets going again.
i can't figure out why refreshing doesn't work.
you expecting more magic component provide :)
the requests going http server, not directly <app-router> component. using html5 pushstate way of handling routes. said, when specify /new new path, component shows desired import and substitutes location.href http://youserver/new. on other hand, when press f5, the browser being redirected http://youserver/new. sounds different actions, right?
so, request http://youserver/new being handled web server , since there no such page, 404.
you have 2 options here:
- teach http server handle
/newyour_router_page.htmlmod_rewriteor like; - specify proper path in
<app-route>s.
the component-way (imho) specify proper path:
<app-route path="/my-router.html?/dash"></app-route> or better stuck hash-like navigation, since works out of box , requires no specific route handling @ all. pushstate more handle redirects outside of current component handler.
hope helps.
Comments
Post a Comment