[英]React Webapp deployed on App Engine displays blank page
Here's the the app.yaml for the deploying build pages to gcloud:这是用于将构建页面部署到 gcloud 的 app.yaml:
runtime: nodejs16
handlers:
# Serve all static files with url ending with a file extension
- url: /(.*\..+)$
static_files: build/\1
upload: build/(.*\..+)$
# Serve all static images with url ending with a image extension
- url: /(.+\.(gif|png|jpg))$
static_files: build/images/\1
upload: build/images/.+\.(gif|png|jpg)$
# Catch all handler to index.html
- url: /.*
static_files: index.html
upload: index.html
Here's the build structure for the build:这是构建的构建结构:
Here are the build scripts for the project:以下是该项目的构建脚本:
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
}
When I deploy app on the gcloud here's the blank page I can find the logo png url but it's not being loaded with other components:当我在 gcloud 上部署应用程序时,这是空白页,我可以找到徽标 png url 但它没有加载其他组件:
https://mintdapp.uc.r.appspot.com/build/images/logo.png
is the image address of the logo是logo的图片地址
Each service in your app has its own app.yaml file, which acts as a descriptor for its deployment.应用程序中的每个服务都有自己的 app.yaml 文件,该文件充当其部署的描述符。 You must first create the app.yaml file for the default service before you can create and deploy app.yaml files for additional services within your app.
您必须先为默认服务创建 app.yaml 文件,然后才能为应用程序中的其他服务创建和部署 app.yaml 文件。 For Node.js, the app.yaml is required to contain at least a runtime entry.
对于 Node.js,app.yaml 需要至少包含一个运行时条目。 For a brief overview, see Defining Runtime Settings .
有关简要概述,请参阅定义运行时设置。 To handle deep links, you need a catch-all rule at the end to always serve index.html.
要处理深层链接,您需要在最后设置一个包罗万象的规则,以始终提供 index.html。 However, before that, you need a rule which maps all your static content.
但是,在此之前,您需要一个映射所有 static 内容的规则。
runtime: nodejs16 # or another supported version
instance_class: F2
env_variables:
BUCKET_NAME: "example-gcs-bucket"
handlers:
- url: /example1
static_dir: example1
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto
You may also try rearranging your static assets in a folder rather than under the root.您也可以尝试将 static 资产重新排列在文件夹中,而不是在根目录下。 Create a directory named "staticfiles" and move all html files to it(except the homepage.html) example as below;
创建一个名为“staticfiles”的目录并将所有 html 文件移动到该目录(除了 homepage.html)示例如下; and then try redeploying
然后尝试重新部署
url: /(.*\.html)
mime_type: text/html
static_files: staticfiles/\1
upload: staticfiles/(.*\.html)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.