Reading .data/ files in static site

Is there any way to read .data/ files in a static site? I’m storing an api key in it.
That’s it. Nice simple question for once :smiley:

Any help would be greatly appreciated.

Thanks in advance! :slight_smile:

I’m not sure, but I don’t think it’s possible because it has the “dot” at the beginning, which makes it a hidden file. You’d probably need ls -a .data/ or some cat command

2 Likes

Hmm, interesting… I can confirm that cat .data/file.name does indeed work - but is there a way to do this client-side? And could that be a security risk and be accessed through the console?.. These are rhetorical questions, by the way, I’m just having a bit of a think.
Thanks for suggesting cat commands.

2 Likes

This is most definitely a security risk

maybe you could use fetch()

fetch(".data/file.name")

don’t try symlinking from outside of .data, it doesn’t work.

the latest advice I received on this subject is not to put it in .data, but it would mean that those files will be copied on fork. you can put them in gitignore, at least.

3 Likes

Hmm, not great as they’ll still be served… I’ll just change it from a static site then.
Thanks for your help!

wasn’t that the point, to be able to read them?

Well, kind of… I mean, it’s a bit contradictory, but I’d like to have it so the code can access it but the client can’t, which I realise now is completely impossible lol :smiley:
The only way to do it is to have a server run all the functions that involve the key, because you’ve got the fs module and you can’t access variables through the console.