node/express Force browser to download file with custom name
<p>I've built a node/express website for my university project that, after searching for an ID of a law, it shows a big table with all files in different formats and languages related with this id.
I use the module "<a href="https://www.npmjs.com/package/http-proxy" rel="noreferrer">http-proxy</a>" to request and serve these files to client.
Nothing wrong when serving xml, xhtml, html and pdf files (every browser is able to directly view them).
I have problems with .zip and .rdf files. Files are not corrupted but they are losing the original name</p>

<ul>
<li>when i click on ZIP icon, it gives me the download prompt, but I'm losing the original file name (the file will be called "proxy" or "proxy.zip", different behaviors on different browsers)</li>
<li>when i click on RDF icon, some browsers opens the file directly in browser, some browsers won't recognize the format, some browsers wants to download it with name "proxy")</li>
</ul>

<p>So I discovered the HTML5 attribute "download" of the tag "a". It just solve my problem, anyway it is not supported on every version of Internet Explorer and Safari. Surfing the web I found some workarounds to add "Right click and save as..." after a div link when the page is viewed in IE or Safari, but this solution is not for me, because i'm not talking about a single link but a table full of links. And my site need to work also on mobile phones.</p>

<p>Is there any way to write some server-side code to force browsers to download files with a custom file name?</p>

<p>Here is the small piece of code of the proxy:</p>

<pre><code>var httpProxy = require('http-proxy');
var proxy = httpProxy.createProxyServer({ ignorePath: true });

app.get('/proxy', function(req , res) {
    var file = req.query.file;
    var realurl = 'http://'+cfg.edb_opt.host+':'+cfg.edb_opt.port+cfg.edb_opt.rest+file;
    console.log('Proxy: serving '+realurl);
    proxy.web(req, res, { 'target': realurl });
});
</code></pre>

<p>All cfg* variables comes from a json configuration file to set the host, port, and starting path where files are contained.</p>

<p>Thanks in advance :)</p>