i have an app.get
that when it's called it downloads a file, here's the code:
app.get("/download-file", async (req, res) => {
if (req.ip === ip0 || req.ip === ip1)
res.download(`${__dirname}/progetto.odt`, "Progetto Esame.odt");
else res.status(403).send("Ip non autorizzato!");
})
I don't think that the if-else thingy is doing something, I saw on this link that I should add that "progetto esame.odt"
as the second parameter and vs code says so too, but it still downloads as download-file
. How can I get this working?
P.S. I'm downloading the file from a react website with a button that calls the API with an href="http://localhost:3001/download-file"
, maybe that's the problem?
P.P.S. I tried with Opera and Firefox, both are not working as they should
Node version: 16.6.2
Express version: 4.17.1