我正试图在上部署我的web应用程序。我的项目遵循这样的结构

app.yaml具有以下内容:
runtime: nodejs14
handlers:
- url: /
static_files: www/index.html
upload: www/index.html
- url: /(.*)
static_files: \1
upload: (.*)但是,当我执行gcloud app deploy --project=MY PROJECT并打开我的站点时,如下所示:

我假设app.yaml文件中有一个错误,但我不明白是什么。有什么想法吗?
发布于 2021-07-01 00:47:49
将第二个URL处理程序更新为:
- url: /(.*\.(svg|png))$
static_files: www/images/\1
upload: www/images/.*\.(svg|png)$然后这样引用您的img src:
<img src="/test.png" alt="oops" width="104" height="142">要添加的一件事是,您也可以使用static_dir作为第二个URL处理程序。这样,可以更容易地组织每个目录的静态文件。将app.yaml更改为:
runtime: nodejs14
handlers:
- url: /
static_files: www/index.html
upload: www/index.html
- url: /static-img
static_dir: www/images在这个例子中,所发生的事情是,位于www/images的图像被映射到/static-img开始的URL上。您可以使用该URL在HTML中引用img。例如:
<img src="/static-img/test.png" alt="oops" width="104" height="142">了解更多信息,请访问:https://cloud.google.com/appengine/docs/standard/nodejs/config/appref#handlers_static_dir
https://stackoverflow.com/questions/68202174
复制相似问题