0

I just followed the setup from http://scotch.io/bar-talk/setting-up-a-mean-stack-single-page-application

This tutorial introduced controllers and services with angular.js for a single-page app..

When I directly visit /pageName, or click the anchor-link for the /pageName route and then press the browser 'Refresh', the page displays:

Error: ENOENT, stat './public/views/index.html'

After reading some answers to similar questions, I changed:

app.get('*', function(req, res) {
    res.sendfile('./public/views/index.html');
});

to:

res.sendfile(__dirname + '/public/views/index.html');

..though now the result is Error: ENOENT, stat '/app/app/public/views/index.html'

2
  • What's the correct full path to index.html? Commented Mar 26, 2014 at 23:52
  • /Users/username/appMainFolder/public/index.html on my local comp.. app/public/index.html on heroku? Commented Mar 26, 2014 at 23:54

1 Answer 1

1

well, first of all, your file is in ./public/index.html , and you are searching in ./public/views/index.html , try:

res.sendfile('./public/index.html');

if that doesen't work,try this:

app.get('*', function(req, res) {
     res.sendfile('index.html', { root: './public' });
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.