I am new to nodejs/expressjs, and I am building a web app and require file download functionality I have a simple code to allow the client side to download files from the server. The GET call is as follows:
app.get('/FileDownload', function(req, res){
var sourcePath = /mydrive/pic.png;
res.download(sourcePath, 'pic.png');
});
Upon clicking download from the frontend, a status of 200 was returned, and using the developer tools I was able to see that the response returned the picture in binary format. However, no files were downloaded to my client.
Network Headers:
Request URL: HOST:PORT/FileDownload
Request Method: GET
Status Code: 200 OK
Response: �PNG
IHDR�I�9usRGB���gAMA���a pHYs���o�d�IDATx^��y�$�u�Y EHKW��յ���$M��@R�(i)�J�̖Z���8=
However, when typing in the get request into the browser directly, the file was able to download. Any advice on how I can make the download prompt appear?