I had recently encountered an issue with a pdf that keeps downloading.
We wanted the pdf to open in a new tab.
- This is a href link to a flask endpoint.
- Clicking on the link keeps make a call to an api and we get a pdf file as response. \
- The pdf file does NOT open in a new tab. Have tried target = “_blank” for href.
- Have also tried javascript window.open.
- Using the window.open , firefox does open the pdf in new tab.
- In chrome, the file is downloading all the time. Cant get it to open in new tab.
After much research, it appears, the api endpoint is adding a header “Content disposition: attachment”.
Once this header is deleted, the pdf started opening in a new tab!