google-app-engine - 页面刷新时 App Engine 为我的 angular2 项目提供 404?

标签 google-app-engine angular

问题与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/

相关文章:

javascript - Typescript - 将拆分后的字符串推送到数组

java - 关于在 GAE 上实现 "inverse document frequency"的建议?

google-app-engine - Google 云存储客户端库 - 将 acl 设置为 "public-read"和 "bucket-owner-full-control"

google-app-engine - google app engine : while using gcloud app deploy , 您无权访问项目

google-app-engine - 具有自定义域的 Google App Engine Channel API

javascript - Angular2 使用标签更新 ng2-charts

node.js - 从 Angular 2 发送电子邮件

angular - Typescript 中全局变量的解构赋值

google-app-engine - Google 云端硬盘按服务帐户更改权限

angular - 重写Azure存储中托管的静态网站的URL