Saturday 20 May 2017

Unable to render static index file from express

I working on Angular application, where I am trying to server the build files from my Angular application through the dist directory in my express. To do this I copy the files generated by ng build and paste them into dist folder of express.

My dist folder looks like below

Dist Folder for Express

I am using the following code to serve the index.html file

this.app.use(express.static(__dirname + '/dist'))

But seem to be getting "Cannot GET /" error

Similarly if I do

this.app.use(express.static(__dirname + '/public'));

it serves the html in the public folder.

As far as my understanding, you can serve static from any folder in express. I am not sure if I am missing something here.



via RRP

No comments:

Post a Comment