2017-10-09 44 views
0
刷新页面后,“不能让错误”

此错误开始显示自己我加$locationProvider.html5Mode(true)我的状态配置上AngularJS后:与html5mode

'Cannot GET error' after refreshing page with html5mode

I`ve搜索了一下,发现此修复程序到服务器端,但它不会是因为某些JSON错误的工作:(也许有人知道如何正确地解决它不用其他制造新的错误)

app.get('*', function(req, res) { 
    res.sendFile(__dirname + '/public/index.html'); 
}); 
+0

您可以显示至少使用一个错误吗? – 31piy

+0

'位置0的JSON中出现意外的标记'此错误显示出来,当我将res.sendFIle添加到后端站点时 – rebilliony

+0

另外,当我删除html5Mode和res.sendFile时,所有工作都正确,除了#!在URL .. – rebilliony

回答

0

试着改变你的代码下面:

app.all('/*', function(req, res) { 
    res.sendFile('index.html', { root: __dirname + '/public/index.html' }); 
}); 
+0

仍然是同样的错误:( – rebilliony

+0

你可以用你的代码创建一个小提琴 –

+0

我不能,它是一个大的应用程序粘贴 – rebilliony