【发布时间】:2019-02-11 22:08:58
【问题描述】:
我们已构建并部署到 Google Cloud App Engine 的 Angular 6 应用程序,该应用程序运行正常。但是,每当使用应用根目录以外的路由刷新浏览器时,我们都会收到 404。
这是我们的 app.yaml 文件:
runtime: nodejs8
handlers:
- url: /
static_files: dist/song/index.html
upload: dist/song/index.html
secure: always
- url: /(.*)
static_files: dist/song/\1
upload: dist/song/(.*)
secure: always
- url: /dashboard
static_files: dist/song/index.html
upload: dist/song/index.html
secure: always
错误是 404 表示“找不到处理程序引用的静态文件:song/dashboard/allshoppers”
所以,它在目录结构中寻找静态文件,但这是我们的 Angular 应用程序中的路由。
【问题讨论】:
-
更新:下面接受的答案会起作用,但最终我们解决了这个问题,而不是部署 Angular 应用程序,我们在本地运行 ng-build,然后将静态资产部署到云中。 (运行时:nodejs10 现在)
标签: angular google-app-engine google-cloud-platform