In my express app, I am trying to display an svg on the client side from the server side. The SVGs I'm serving come from the directory, /svg_library, which contains 3 svgs:
/svg_library
- svg1.svg
- svg2.svg
- svg3.svg
In order to serve svg1.svg to the client, I use app.use(express.static('svg_library'))
.
The client then has access at localhost:3000/svg1.svg.
Question 1: how do I serve just a single file (svg1.svg), so that a user cannot have access to the other files (svg2.svg and svg3.svg) in svg_library?
Question 2: From an efficiency and security perspective, is it better to use express.static or directly serve the svg in the http response (changing the content-type to img/svg+xml)?