How does nodejs add header? to this url before jumping to another url

I want to download directly when I open a link. By default, opening a link will automatically open a preview in the browser. Can nodejs add header to the url before opening the link?

exports.download = async (ctx,next) => {
    ctx.type = "application/octet-stream"
    ctx.set("Content-Disposition","attachment;filename=name")//
    ctx.redirect(ctx.request.query.path) //
}

I am currently using redirects without adding this header.
if I write this url in a route in iframe form, what I download is the code for the iframe tag.

Mar.18,2021
  • Express routing problem

    I am a novice. I have just come into contact with the node.js and express frameworks. I have configured routing according to the online tutorial, but there are some problems, as follows: first of all, the file structure is as follows: index.js:...

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3201e-2bdf2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3201e-2bdf2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?