首页 > 解决方案 > BUILD 后 REACTJS 中的空白页

问题描述

我还在学习所以请放轻松...

我已经进行了部署和构建应用程序。但只是初始页面显示内容......所有其他页面,显示为空白。在控制台中看起来他找到了页面,但没有打开。

此错误出现在控制台中:

Uncaught SyntaxError: Unexpected token '<'  2.283742ca.chunk.js:1 
Uncaught SyntaxError: Unexpected token '<'  main.9ee80443.chunk.js:1

我真的不知道如何解决。

网站已上线。如果有人可以帮助...给我一些光... http://calces.com.br | http://calces.com.br/admin/usuarios

在这两个例子中。来自 chunk.js 的响应是不同的......

我已尝试将其放在 client/public/.htacess 上,但也不起作用

<IfModule mod_rewrite.c>

  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule . /index.html [L]

</IfModule>

我的 server.js

app.use(express.static(path.join(__dirname, "client/build")));
app.get("*", (req, res) => {
    res.sendFile(path.join(__dirname, "client/build", "index.html"));
});

标签: node.jsreactjsexpress.htaccessbuild

解决方案


推荐阅读