I have a link in my React app that is supposed to open a PDF in another page, but for some reason Google Chrome is redirecting me to the React application instead of opening the API endpoint that renders the PDF. The URL for the PDF is /api/file/:_id
and my React app is located at /
. Below are my Express routes:
app.use("/api/file", fileRouter)
app.get("*", (req, res) => {
return res.sendFile(path.join(__dirname, "/front/build/index.html"))
})
When I click on the link:
<a href={`/api/file/${invoice._id}`} target="_blank" rel="noreferrer">link</a>
Google Chrome keeps opening the React page instead of the PDF file, whereas Safari opens the PDF just fine.
Thank you for any help or insight you can provide.