我正在 Google Cloud (App Engine) 上部署我的 Angular 7 应用程序。
该应用程序运行良好,但我有一些问题......
首先是如何处理 html5 模式,这样当我在路由上(例如https://myapp.com/my-route/)并且我刷新浏览器时,服务器应该回复我的 index.html,并且角度应该执行路由,而不是返回 404 错误页面。
我怎样才能做到这一点?你能帮助我吗?
非常感谢!
我正在 Google Cloud (App Engine) 上部署我的 Angular 7 应用程序。
该应用程序运行良好,但我有一些问题......
首先是如何处理 html5 模式,这样当我在路由上(例如https://myapp.com/my-route/)并且我刷新浏览器时,服务器应该回复我的 index.html,并且角度应该执行路由,而不是返回 404 错误页面。
我怎样才能做到这一点?你能帮助我吗?
非常感谢!
这是我的 app.yaml,它工作正常,如果您有任何提示,请分享:)
runtime: python27
threadsafe: true
skip_files:
- ^(?!dist)
handlers:
- url: /en/(.*\.(gif|png|jpg|css|js)(|\.map))$
static_files: dist/en/\1
upload: dist/en/(.*)(|\.map)
- url: /it/(.*\.(gif|png|jpg|css|js)(|\.map))$
static_files: dist/it/\1
upload: dist/it/(.*)(|\.map)
- url: /en/(.*)
static_files: dist/en/index.html
upload: dist/en/index.html
- url: /it/(.*)
static_files: dist/it/index.html
upload: dist/it/index.html
- url: /
static_files: dist/en/index.html
upload: dist/en/index.html
error_handlers:
- file: index.html