简体   繁体   English

App Engine 上部署的 React Webapp 显示空白页面

[英]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 但它没有加载其他组件:

部署在 apppot 上

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.

相关问题 Firebase react.js 应用已部署 - 空白页 - Firebase react.js app deployed - blank page Flutter web 应用程序在部署到 firebase 主机后返回空白页 - Flutter web app is returning blank page after being deployed to firebase hosting 如何为一组用户部署部署在 Docker 和 GCP 上的 React webapp - How to deploy React webapp deployed on Docker and GCP only for a set of users 部署在 Google App Engine 标准上的 Dash 应用不断刷新 - Dash app deployed on Google App Engine standard continuously refreshing 在 Google App Engine 上反应应用程序崩溃循环 - React app crash loop on Google App Engine Google App Engine 上的身份验证(网页) - Authentication on Google App Engine (web page) 检查是否从部署在 kubernetes 引擎上的应用程序连接到 GCP CloudSQL Postgres 实例 - Check if connected to GCP CloudSQL Postgres instance from App Deployed on kubernetes engine React App 在本地主机上工作,在 firebase 上部署后空白 - React App working localhost, blank after deployment on firebase 部署在 s3 存储桶上的 React App 仅显示主页。 哈希路由器不工作 - React App deployed on s3 bucket shows only the homepage. Hash router not working Google App Engine ModuleHostname:不是 App Engine 上下文 - Google App Engine ModuleHostname: not an App Engine context
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM