javascript - Can't serve static files in express -
im using jade express. express code serving static files:
app.use(express.static(__dirname + "/frontend"));
and jade code in layout.jade:
link(rel='stylesheet', href='/css/style.css') script(src='/bower_components/angular/angular.min.js') script(src='/app.js')
for reason stackoverflow doesn't allow me show folder structure have every file mentioned here in frontend folder located in root directory. tried commenting out express.static , using full path doesn't work.
i'm getting 404 error.
the above code posted expose assets on /
. expose them on /frontend
, need use following.
app.use(express.static("frontend", __dirname + "/frontend"));
if want create “virtual” (since path not exists in file system) path prefix files served express.static, can specify mount path static directory, shown below:
app.use('/static', express.static('public'));
Comments
Post a Comment