我正在尝试使用app Engine在Google Cloud平台上托管一个Angular应用程序。问题是,在我成功部署之后,我可以访问它大约2-3分钟,点击刷新,没有得到HTTP错误404,但在这2-3分钟后,我在Chrome中收到了以下错误(同事在他们的机器上也收到了相同的错误):

我尝试使用以下命令构建我的angular应用程序:
ng build --prod
ng build --prod --base-href sep6-appAngular应用文件夹结构:
- dist/
- sep6-app/
- app.yaml我的app.yaml:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
static_files: sep6-app/index.html
upload: sep6-app/index.html
- url: /.*
static_dir: sep6-app在GCP中,我的存储桶包含:
- app.yaml
- sep6-app/一件事是,如果我像这样在app.yaml中设置URL,然后重新部署:
- url: /
static_files: sep6-app/index.html
upload: sep6-app/index.html
- url: /
static_dir: sep6-app我可以毫无问题地访问我的应用程序,但如果我刷新任何页面,我会得到404错误,我理解这是由于Angular处理路由的方式所致。然而,我不明白为什么让"- url: /.*“在短时间内工作,然后就停止了?
我正在使用(以防需要):
Angular CLI: 9.1.7
Angular: 9.1.9对于为什么会发生这种情况,以及如何解决这一问题,有什么想法或想法吗?谢谢!
发布于 2020-05-25 05:49:26
通过使用以下app.yaml,我成功地让它工作起来:
runtime: python38
service: default
handlers:
- url: /(.*\.(gif|png|jpg|less|json|woff|woff2|ttf|eot|scss|css|js|ico|svg)(|\.map))$
static_files: sep6-app/\1
upload: sep6-app/(.*)(|\.map)
- url: /(.*)
static_files: sep6-app/index.html
upload: sep6-app/index.htmlhttps://stackoverflow.com/questions/61970036
复制相似问题