Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 未捕获的语法错误:意外标记'<';在嵌套的路由清单和块上_Reactjs_Express_React Router - Fatal编程技术网

Reactjs 未捕获的语法错误:意外标记'<';在嵌套的路由清单和块上

Reactjs 未捕获的语法错误:意外标记'<';在嵌套的路由清单和块上,reactjs,express,react-router,Reactjs,Express,React Router,我在apache上设置了一个带有express后端的react网站。以下是我的设置: server.js: app.use(express.static(path.join(`${__dirname}/frontend`, 'build'))); app.get('/*', function (req, res) { res.sendFile(path.join(`${__dirname}/frontend`, 'build', 'index.html')); }); 我的包json中的主页:

我在apache上设置了一个带有express后端的react网站。以下是我的设置:

server.js:

app.use(express.static(path.join(`${__dirname}/frontend`, 'build')));
app.get('/*', function (req, res) {
res.sendFile(path.join(`${__dirname}/frontend`, 'build', 'index.html'));
});
我的包json中的主页:

"homepage":"."
现在,当我使用www.mydomain或www.mydomain/something时,我的网站运行完全正常。但是当我加上另一个“/”时,我得到了
未捕获的语法错误
,因为假设我使用www.mydomain/something/else,我的网站不会在mydomain/manifest.json(它们所在的位置)上搜索块文件和清单文件,而是在mydomain/something/manifest.json上,我得到了2个块错误和1个manifest.json错误 当我使用客户端路由时,我可以使用这些路由,但当我刷新或键入这些路由时,我会遇到这个问题。因此,如果路由的“/”数超过1,它将在错误的位置搜索清单json和块


如果你需要更多的信息,请告诉我。我知道错误发生的原因,但我不知道如何修复它

,因此基本上您希望任何路径后跟
“/”
,它应该能够渲染文件?是的。我想不能呈现我的域/某物/某物/某物等等。它只在“/something”上工作,但只要我添加“/something/anywhere”,它就会使用错误的url来获取清单,并出现错误尝试
app.get('/*/**',function(req,res){
。我还没有尝试过这个方法。@Sohan如果你删除这一行,
res.sendFile(path.join(
${uu dirname}/frontend
,'build','index.html'),它就不工作了
然后用say
res.send('Hello World!')回复即可。
那么
/*
应该可以工作了我尝试了这个方法,并且对我有效。检查一下,您尝试回复的路径是否有问题?