If I define
app.use('/*', express.static(path.join(__dirname, '../pub/index.html')));
Then it appears that I need to provide at least one character after / in my url to get index.html. If I define the route with just /
, I get 404 for anything in the browser.
How do I get a default file served up with just /
?
You could use serve-static :
app.use(serveStatic(path.join(__dirname, '../pub'), {'index' ['index.html']}));
It should serve the index.html , which is located in ../pub , if you call eg localhost:3000
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.