Polymer 应用程序的服务器端路由

Server side routing for Polymer Application

如果我使用 "polymer serve" 启动网络应用程序,刷新任何页面都会显示我所在的相同页面。

使用我自己的 go lang 服务器在页面刷新时出现 404 错误。

我必须将每个页面请求重新路由到显示第一个应用程序页面的 index.html。但是我不想显示第一页。

如何在服务器端路由以获得与 "polymer serve" 相同的行为?

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.

后台服务器的配合类似于Java中的RequestDispatcher.forward()。你应该找到如何使用 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>

参考。 https://github.com/PolymerElements/app-route#hashes-vs-paths