First of all I don't have any idea how to serve files to users. I want my website to access the api and return some files for the user to download? Is it right to send files using the api? If yes then how should I do that?
Asked
Active
Viewed 64 times
1
-
Have you tried googling it? There's a ton of articles which guides you step by step how to do that. – Sebastian Kaczmarek Sep 13 '19 at 06:28
1 Answers
0
It depends on the nature of the file and whom are you serving, if files contains data for specific user, add authorisation for the user and check if the user is authorised or not.
you can serve files from node server like this
app.use('/static', express.static('public'));
Now, you can load the files that are in the public directory from the /static path prefix.
http://localhost:3000/static/images/kitten.jpg
add the files in public folder

virender nehra
- 470
- 6
- 12