V
V
Vadim_Sabirov2021-05-19 22:22:00
Express.js
Vadim_Sabirov, 2021-05-19 22:22:00

How to regulate access to static files in express?

The site is a school of online courses. There are several courses, inside which there are mp4 and pdf files. The files are located in the files folder. I gave them access via express.static(): But I'm worried that a person who does not have access to subscription B will be able to open pdf and audio files through the address bar. Is there any way to check if a person has access to a subscription, and thus secure the files?
app.use('/files', express.static('files'))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2021-05-19
@Vadim_Sabirov

It is better to /files/:filenamehang up on the handler and check the subscription there. And already give a file or a 403 error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question