I'm trying to display PDF files on the page. They are stored on the server. I do not want use public folder as anyone can access it.
I've tried all solution I found, but none seems to work with pdf's:
app.use(express.static('uploads'));
app.use(express.static(path.join(__dirname, 'uploads')));
app.use(express.static(__dirname + '/uploads'));
Strangely enough, I'm able to display images from 'uploads' folder:
<img src='/randomImage.jpg' />
but not pdf's:
<object data='/randomPdf.pdf'></object>
or
<iframe src='/randomPdf.pdf'></iframe>
I tried to restrict the public folder for not authorized users, but I'm doing something wrong, as it's not working for me:/
app.use(authUsers, express.static('public/uploads'))
Forget to mention that I'm using MongoDB to store ref paths to the files. I fetch all data from DB and then display each pdf on the page.
Thank you in advance.