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

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -