javascript - 为什么我的反应网络应用程序返回一个白色/空白页面?
问题描述
我一直在尝试托管一个使用 create-react-app 创建的 React Web 应用程序。我正在使用 Hostinger。我得到的只是这个白色/空白页。
在我的本地服务器上运行良好,在 github 页面上运行良好。目前,我将 package.json 中的“主页”设置为正确的域。我还尝试将其设置为“。” 正如一些人对其他类似问题的建议。
起初我在控制台上遇到 2 个错误:
- 样式表未加载,因为它的 MIME 类型“text/html”不是“text/css”。
- SyntaxError:预期的表达式,得到“<”。
经过大量调整和重建后,我仍然得到白色/空白页面,但现在控制台为我提供了多个文件的 404 状态。他们是:
- 静态/css/main.0d200d10.chunk.css
- 静态/js/2.f331c7cc.chunk.js
- 静态/js/main.0e5eb86e.chunk.js
它现在还为 2 个单独的文件提供 1 个警告:
- 源“<url>/static/js/2.f331c7cc.chunk.js”的 <script> 加载失败。” 和来源“<url>/static/js/main.0e5eb86e.chunk.js”。
这就是 index.html 的样子
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Cachorro Sensível Filmes</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
该网站是https://cachorosensivel.com.br
任何想法都非常受欢迎。
编辑:我回到重新上传 .htaccess 后提到的 2 个原始错误。如果我在脚本标签中指定“type=text/jsx”并从链接标签中删除“rel=stylesheet”,我不会收到任何错误,但它仍然是空白的。
我正在 Chrome 和 Firefox 上进行测试,并且我已经清除了缓存。
解决方案
我搞砸了上传到文件管理器。它进入 public_html -> 文件/静态文件夹 -> 静态文件夹 -> 文件。
推荐阅读
- django - 在 Django 中制作代理身份验证服务器
- spring - 非默认端口上的 Docker-compose、spring app + mongoDB
- django - Django CRUD - 创建和更新视图不起作用
- javascript - 如何在 chrome devtools 中以角度调试 .ts 文件?webpack 没有构建调试
- python - 如果值重复 X 次以上,则删除 pandas 行
- c++builder - 如果在c ++中可以写多少个条件
- c# - Visual Studio 2019 IntelliSense 已更改(如何获取先前的行为?)
- java - Swagger codegen 插件生成对 getter 的约束
- java - 如何在java中读取字符之间的多个标记?
- excel - 对两个 VLOOKUP 公式使用 OR