Disable direct file downloads on NodeJS

@Teodor May I ask you to provide you some more information (screenshots) how to restrict/protect downloading files directly by typing full URL path to files?

Server model: NodeJS
I have folder /public/export and I want so that downloading files from this folder would be possible only via Server Connect - File download action, not by typing URL path.

Just don’t put the files in the public folder :slight_smile: When they are outside the public folder, they can’t be accessed by a direct link.

I tried that but in that case - fileDownload step returns - not found.

Can you please show me the exact location in your project folder (files view in Wappler)?

Here you go:
image

I just tested the same and it works perfectly fine:

How do you test this exactly?

Same as you:

But how do you test your server action? How do you run it?

I have an anchor button which executes Server Connect action configured via routes.
I just added additional file download step with new path (pointing to root/export) and disabled working one (which points to public folder).

can you post your button code please, as well as a screenshot your route config?

@Teodor let me guess, you’re not using Docker

@Notum let me guess, you’re using Docker

Folder export (/export/) is not exposed inside Docker container, as checked on docker-compose.yml of Development environment

1 Like

Anchor button:
image

Route:
image

Your screenshot shows test/test server action while your route and code point to another one :slight_smile:
Which is your server action exactly what are its steps?

Yeah, this screenshot is wrong.

No, i am not using docker.

@Notum follow the steps in this post:

This will allow you to expose your “export” folder into your Docker container.

The more appropriate approach is to expose a more generic folder “storage”, which inside you put the “export” folder, so it comes:

/storage/export/

Also a note for newbies using Linux, the initial slash (/) is specific to Wappler, it refers to the app’s directory, not to the actual filesystem / in Unix/Linux

3 Likes

@Apple Thank you very much! Did exactly according to your linked topic and that did the trick! New lesson learned.

@Teodor Thanks for helping!

1 Like