Replies: 3 comments
-
Did you try disabling browser cache? |
Beta Was this translation helpful? Give feedback.
-
I'm able to delete express()
.use(createProxyMiddleware({
target: "https://demo.borland.com",
changeOrigin: true,
onProxyRes(proxyRes) {
delete proxyRes.headers["content-disposition"];
}
}))
.listen(8000) https://demo.borland.com/testsite/download_testpage.php original: curl -X HEAD -I https://demo.borland.com/testsite/downloads/downloadfile.php\?file\=Hello.txt\&cd\=attachment+filename http-proxy-middleware: curl -X HEAD -I http://localhost:8000/testsite/downloads/downloadfile.php\?file\=Hello.txt\&cd\=attachment+filename In the proxied response you'll see EDIT: reproducible example |
Beta Was this translation helpful? Give feedback.
-
Yes, I did. My cache is practically always disabled when the DevTools are open: Unfortunately, I didn't get to try your suggested solution, though I'm pretty sure I tried it in the exact same way. I will see if I can do another test run tomorrow or on Monday. Thank you |
Beta Was this translation helpful? Give feedback.
-
yarn why http-proxy-middleware
ORnpm ls http-proxy-middleware
output (mask private folder names with *****)Please verify that you've followed these steps
[ x] - I've updated to latest
http-proxy-middleware
.Describe the bug
I am trying to use
http-proxy-middleware
to request PDF files from a server, because the server's response contains theheader. This forces the requesting browser to download the file instead of opening it in its PDF reader (see https://stackoverflow.com/questions/9195304/how-to-use-content-disposition-for-force-a-file-to-download-to-the-hard-drive)
I tried removing the header with
as well as:
Unfortunately, I couldn't make a fully working example because I don't know of any public servers that serve PDF with that 'content-disposition' header.
Expected behavior
I expected that the 'content-disposition' header would be removed from the proxy response allowing the PDF file to be displayed in the browser's PDF reader. What I see in the browser's dev tools though is that the header is still part of the response.
http-proxy-middleware
configurationsee above
Server (please complete the following information):
Additional context
Running
console.log
before and afterdelete proxyRes.headers['content-disposition']
prints the following:So it looks like the header is gone but in the network tab of the browser's dev tools, I still get to see this:
Beta Was this translation helpful? Give feedback.
All reactions