0
SEO를 위해 Angular JS 앱에서 html5 모드를 사용하려고합니다. 그러나 익스프레스가 index.html을 요청하면 문제가 발생했습니다. 딥 링크가 작동하지 않아 페이지를 새로 고칠 수 없습니다.Angular html5 모드에서 index.html 서비스가 작동하지 않습니다.
App.js
app.use(serveStatic(path.join(__dirname, 'public')));
app.use(serveStatic(path.join(__dirname, 'node_modules')));
app.use(serveStatic(path.join(__dirname, 'app_client')));
app.use('/api', routesApi);
app.all('/*', function(req, res, next) {
res.sendFile('./app_client/index.html', { root: __dirname });
console.log("send index");
});
이미 접근, 다양한 소스에서 많은 연구를 시도 같은
app.get('/', function(req, res) {
res.sendFile('index.html');
});
또는
router.get('/', function(req, res) {
res.sendFile(path.join(__dirname, 'app_client', 'index.html'));
});
또는
app.get('/*', function(req, res) {
res.sendFile(__dirname + '/index.html')
});
아무 것도 작동하지 않는 것 같습니다. 나는 뭔가 내 코드에서 틀린해야한다는 것을 알고 있지만, 나는 어디에 있는지 모른다.