1

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?

CriticalRebel
  • 63
  • 1
  • 7

1 Answers1

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