Javascript 如何使用GAE中的app.yaml获取静态文件的url?
我有一个create-react-app-Build目录,将其放在云存储上,并在中添加了app.yaml文件:Javascript 如何使用GAE中的app.yaml获取静态文件的url?,javascript,python,google-app-engine,create-react-app,app.yaml,Javascript,Python,Google App Engine,Create React App,App.yaml,我有一个create-react-app-Build目录,将其放在云存储上,并在中添加了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 托管在应用程序引擎上,瞧,它工作了
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。
我尝试将处理程序url中的“/”替换为“/*”,但结果返回一个空白页:(
有什么建议吗?:)首先,您有重复的
/
处理程序。你永远也找不到第二个处理程序
您可以在处理程序中使用一些正则表达式来提供任何类型的静态文件,如下所示:
- 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
找到了解决办法。当我使用static_dir时,每个以处理程序的url开头的url都会被包含在内。考虑到每个静态文件都在build/static目录中,我只使用了url:/static来处理需要从该文件夹处理的任何内容 createreact应用程序创建了几个.json文件,它们位于build dir中,所以我只是分别指向它们,因为只有几个 完成所有这些之后,我可以使用url:/.*来暗示任何其他url都应该指向index.html页面 这是可行的:(第一个处理程序可能是冗余的)
这是一个静态站点还是一个静态站点?不一样的事。。。如何部署它?我在GCS中转储build文件夹和app.yaml,然后使用控制台的SSH复制文件并将其部署到AppEngine。比如:好的,它是一个GAE应用程序,但只使用GCS作为存储,GAE部署使用GCP shell完成。我如何访问.php文件?
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