问题与How do I make Angular 2 routing work with App Engine on page refresh? 非常相似但是我没有足够的分数来评论,它说不要在答案中提出问题。
除了它是 appspot 上的一个静态托管站点,并且使用了 angular cli dist 文件夹之外,无论如何都是同样的问题:
Project
|
+--dist
|
+--index.html
+--inline.js
+--inline.map
+--main.bundle.js
+--main.map
+--styles.bundle.js
+--styles.map
+--app.yaml
+--index.yaml
我尝试将我的 app.yaml 更改为与上面链接的 Dan 的答案类似的内容,但无法解决?这是 app.yaml 文件:
application:
version:
runtime: python27
threadsafe: true
api_version: 1
handlers:
- url: /(.*\.js)
static_files: dist/\1
upload: dist/(.*\.js)
- url: /(.*\.map)
mime_type: application/octet-stream
static_files: dist/\1
upload: dist/(.*\.map)
- url: /
static_files: dist/index.html
upload: dist/index.html
- url: /(.*)
static_files: dist/\1
upload: dist/(.*)
谢谢
最佳答案
试试这个处理程序:
- url: /(.*\.(gif|png|jpg|css|js)(|\.map))$
static_files: dist/\1
upload: dist/(.*)(|\.map)
- url: /(.*)
static_files: dist/index.html
upload: dist/index.html
如果您的应用使用更多文件扩展名,请在第一个处理程序中添加文件扩展名。
适用于我的应用...
关于google-app-engine - 页面刷新时 App Engine 为我的 angular2 项目提供 404?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39944208/