angularjs - Express serving index.html from Angular html5 mode not working -
i'm trying use html5 mode in angular js app sake of seo. however, faced problem express serving index.html request. deep linking didn't work , cannot refresh page.
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"); });
i try many researches many sources, approach such
app.get('/', function(req, res) { res.sendfile('index.html'); });
or
router.get('/', function(req, res) { res.sendfile(path.join(__dirname, 'app_client', 'index.html')); });
or
app.get('/*', function(req, res) { res.sendfile(__dirname + '/index.html') });
none seems work. know must wrong in code, don't know where.
found answer @ lasts
app.get('/*', function(req, res, next) { res.sendfile(__dirname + '/app_client/index.html'); }
Comments
Post a Comment