【发布时间】:2018-12-06 16:51:24
【问题描述】:
我有一个使用 create-react-app 的 React.js 网站,刚刚从 Firebase 托管迁移到 Google App Engine 标准环境。
使用 Firebase 托管,我可以创建像 https://example.com/route 或 https://example.com/newRoute/123 这样的路由,Firebase 会知道为这些路由中的任何一个提供 index.html。
我想对我们应用程序的任何路由进行通配符以使用 index.html,同时排除 .js 和 .css 文件。如果我只使用通配符 /(.*) 那么对 main.js 文件的请求也会解析为 index.html。
这是我们的处理程序配置
handlers:
- url: /
secure: always
application_readable: false
static_files: build/index.html
require_matching_file: false
upload: build/index.html
- url: /login
secure: always
application_readable: false
static_files: build/index.html
require_matching_file: false
upload: build/index.html
- url: '/(.*)'
secure: always
application_readable: false
static_files: "build/\\1"
require_matching_file: false
upload: 'build/.*'
在当前配置中,我创建的每条路由都必须注册为处理程序。我希望找到一个解决方案,其中所有当前路线和未来路线都可以通过通配符处理。
【问题讨论】:
-
您要上传的总是
build/index.html吗? -
是的。我想一直上传
build/index.html,除非 index.html 请求我们的静态资源(js、css、png、jpg、svg)。
标签: google-app-engine app.yaml