
[英]Google App Engine fails when trying to upload static .mp3 files through app.yaml
[英]How to get any url to work for STATIC FILES with app.yaml in GAE?
我有一个create-react-app Build目录,将其放在Cloud Storage上,并在其中也添加了app.yaml文件:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: build/index.html
upload: build/index.html
secure: always
- url: /
static_dir: build
托管在应用程序引擎上,瞧!
但是,虽然example-domain.com/有效,但example-domain.com/abc无效。 我收到错误消息:找不到此服务器上找不到请求的URL / abc。
我尝试在处理程序网址中将“ /”替换为“ /.*”,但结果返回一个空白页:(。
有什么建议么? :)
找到了解决方案。 原来,当我使用static_dir时,包括以该处理程序的URL开头的每个url。 鉴于每个静态文件都在build / static目录中,因此我只将url:/ static用于需要从该文件夹处理的所有内容。
Create-react-app会在构建目录中创建多个.json文件,因此我只是单独指出了它们,因为那里只有几个。
完成所有这些操作后,我可以使用url:/.*暗示任何其他url都应仅指向index.html页面。
这有效:(第一个处理程序可能是多余的)
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: build/index.html
upload: build/index.html
secure: always
- url: /static
static_dir: build/static
- url: /manifest.json
static_files: build/manifest.json
upload: build/manifest.json
- url: /asset-manifest.json
static_files: build/asset-manifest.json
upload: build/asset-manifest.json
- url: /service-worker.json
static_files: build/service-worker.json
upload: build/service-worker.json
- url: /pageIcon.png
static_files: build/pageIcon.png
upload: build/pageIcon.png
- url: /.*
static_files: build/index.html
upload: build/index.html
secure: always
首先,您有/
重复处理程序。 您将永远不会到达第二个处理程序。
您可以在处理程序中使用一些正则表达式来提供所需类型的静态文件,如下所示:
- url: /(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg|html))$
static_files: build/\1
upload: build/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg|html)$
secure: always
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.