[英]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.