简体   繁体   中英

Sending multiple Files or folder using node.js Express

So my problem is i was originally serving my files i believe static using

app.use(express.static(clientPath));

Since then i realised i need to get some pentameters from the connecting url. now when i use the connection as below i only get the index.html so there is no css with it or any images so i was wondering how i can send all my files in the client folder?

 app.get('/username/:userID/hash/:hash', function (req,res) {
   
       var userDetails = {
           username : req.params.userID,
           hash : req.params.hash    
       }
  
       res.sendFile(path.join(__dirname + '/../client/index.html'));
  
 });

Continue to use the static module to serve static files.

Make sure that the URLs you use to reference CSS, images, etc are still correct (since the URL of the HTML document has changed so relative paths will resolve differently).

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM