expressjs / serve-static

Serve static files
MIT License
1.38k stars 227 forks source link

Issue with Example Code #148

Closed stingwraith closed 2 years ago

stingwraith commented 2 years ago

I'm not too sure why, but I had to change your example code a bit for it to work in conjunction with serve-index, like so:

app.use("/shared", serveStatic('shared', { index: ['.jpg', '.png'] }))

dougwilson commented 2 years ago

Thanks for the feedback. Which example code are you referring to, as there are multiple and I don't think there are any with serve-index.

stingwraith commented 2 years ago

My apologies, I should have been more specific.

This is strictly in relation to the "Serving using express" portion.

The usage of serve-index is only from my code, but I can imagine others would want to use them in conjunction as well(provided my understanding of each of their respective functionality is correct).

dougwilson commented 2 years ago

You can certainly use them in conjunction. But I don't know why you had to change the example, either. I just tried the example you are referring to and added app.use(serveIndex('public/ftp')) and it works just fine... You'll need to provide further details on your exact set up or something so we can help understand what is going on.

dougwilson commented 2 years ago

Specific example of using them together you can find on the serve-index page: https://github.com/expressjs/serve-index#serve-directory-indexes-with-express as it is more serve-index specific docs than serve-static.