简体   繁体   English

使用 AWS Amplify 部署时,React JS 应用程序变为空白屏幕

[英]React JS App becomes blank white screen when deployed with AWS Amplify

I have a React JS app that works on local host, but when I deploy to AWS amplify displays as a blank white screen with no body.我有一个可以在本地主机上运行的 React JS 应用程序,但是当我部署到 AWS 时,放大显示为没有正文的空白屏幕。 The browser tab shows the correct title and icon.浏览器选项卡显示正确的标题和图标。

The page returns status code 403 and I believe there is a CORS issue?该页面返回状态码 403,我相信存在 CORS 问题? I have been unable to correct this in my code or on the Amplify console.我无法在我的代码或 Amplify 控制台上更正此问题。 Can someone point me towards what is causing my problem?有人可以指出导致我的问题的原因吗? I have successfully deployed a different React app with Amplify.我已经使用 Amplify 成功部署了一个不同的 React 应用程序。

开发控制台中缺少正文

读取错误

In my case I needed to change the homepage url in the package.json to match my Amplify URL. In my case I needed to change the homepage url in the package.json to match my Amplify URL. To do this add, or modify, the following line in your package.json:为此,在 package.json 中添加或修改以下行:

 "homepage": "{Amplify-URL}/#/"

The Amplify URL can be found in the Amplify console under App settings -> Domain Management -> URL. Amplify URL 可以在 Amplify 控制台的应用程序设置 -> 域管理 -> URL 下找到。

Hopefully this helps!希望这会有所帮助!

In the build settings ie the amplify.yml file, you need to specify under artifacts the base directory which webpack or the build tool being used will generate.In my case this is the dist directory, because due to running yarn build command.在构建设置(即 amplify.yml 文件)中,您需要在 artifacts 下指定 webpack 或正在使用的构建工具将生成的基本目录。在我的情况下,这是 dist 目录,因为运行 yarn build 命令。

 artifacts:
    # IMPORTANT - Please verify your build output directory
    baseDirectory: dist

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Heroku-Express和React应用程序在部署时显示空白屏幕 - Heroku - Express and React app showing blank screen when deployed AWS Amplify Authenticator React Native Tab Bar Navigation 白屏而不是渲染我的应用程序 - AWS Amplify Authenticator React Native Tab Bar Navigation white screen instead of rendering my app React 18、react-router-dom、Amplify - 本地主机中的空白屏幕 - React 18, react-router-dom, Amplify - Blank white screen in local host React-Redux:单击按钮后页面变为空白屏幕并且不出现组件 - React-Redux: Page becomes blank white screen after clicking a button and components do not appear 部署到AWS时React应用程序路由问题 - React app routes issue when deployed to AWS 当我尝试更新 state 中的数组时,React App 变为空白 - React App becomes blank when I try to update an array in the state firebase 部署和托管 React App 时获取空白页面 - Getting blank page when React App is deployed and hosted by firebase React.js - 当应用程序上传到 Amplify 时,state 变量未定义 - React.js - state variable is undefined when app is uploaded to Amplify 使用 puppeteer 测试 AWS 放大反应应用程序 - Testing with puppeteer an AWS amplify react app 部署到 github 页面的 React 应用程序是空白的 - Deployed React app to github pages is blank
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM