0

Right now i want to make a node.js use express.js that can use a path for the website.

app.use('/upload', express.static(path.resolve('./upload')));
app.use('/static', express.static(path.resolve('./public')));

I use those two to make path to the website. with upload and public have a diffrence .html. The problem is only the public one work and the upload not. Is using app.use like this is possible?

Qwerpotify
  • 49
  • 6

1 Answers1

0

ExpressJS works on a concept of "middleware" which are list a list of functions that the request passes through getting modified along the way. You can use as many middleware as you want for a request.

Here, you are using one of the express's default middleware - express.static.

So, yeah, use as many as you want.

On a side note, it's not generally a good idea to serve static assets with NodeJS. Instead, use a separate server to serve static assets. Read: https://stackoverflow.com/a/9981974/4382683

Faizuddin Mohammed
  • 4,118
  • 5
  • 27
  • 51