Express.js send() will not prompt download through email client

I have an api that I'm testing at the moment. I'm using ngrok to make my local server that has the api code visible to the internet. If, for example, I have a link like,002, what should happen when you click on that link is a spreadsheet is dynamically built using exceljs and sent to the client using express. Here is that snippet of code:

const buffer = await workbook.xlsx.writeBuffer()
res.set("Content-Type", "application/octet-stream")

The weird thing that I can't figure out is when you just copy and paste that ngrok link into your browser it prompts the spreadsheet download as I hoped would happen. When you send someone that link through an email client and try to click it, it opens a new tab like it's going to prompt the download, but after a second or two the tab just closes and nothing else happens. Is this because of some email client security? Is there a way to allow the download?

Read more here:

Content Attribution

This content was originally published by thesofaking at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: