Tusshu
Tusshu

Reputation: 1744

Server side routing for Polymer Application

If I use "polymer serve" to start web application, refreshing any page shows the same page I am on.

Using my own go lang server gives me 404 error on page refresh.

I have to reroute every page request to index.html which shows the first application page. But I don't want to show the first page.

How to route on server side to get same behavior as "polymer serve"?

Upvotes: 0

Views: 165

Answers (1)

Frank R.
Frank R.

Reputation: 1852

By default app-location routes using the pathname portion of the URL. This has broad browser support but it does require cooperation of the backend server.

The cooperation of the backend server is something like RequestDispatcher.forward() in Java. You should find how to do it with Go lang.

An app-location can be configured to use the hash part of a URL instead using the use-hash-as-path attribute, like so:

<app-location route="{{route}}" use-hash-as-path></app-location>

Ref. https://github.com/PolymerElements/app-route#hashes-vs-paths

Upvotes: 1

Related Questions