Protecting static folder on server side
I have a folder with statically built HTML, CSS and JS assets (think static dashboard) that I would like to protect using sessions. I don't know the HTML files ahead of time, so I am hoping that there is a way to serve and protect a whole folder. I tried using serveStatic from h3, but got confused on how to actually implement that and how it fits into the Nuxt 3 file-based routing.
Any pointers would be appreciated!
4 Replies
why do you want to protect it?
protecting static files will be tricky depending on the use case
but you could e.g. serve them via nitro + useStorage and check auth before
it's an internal dashboard built with Observable that I only want to show to logged in users. Observable framework has their own cli to build those static HTML files and assets. I'll check into Nitro, but I suspect it will be tricky to serve that folder. only to logged in users. Many thanks for responding!
Just for future reference, the use case I described is trivial with express:
then it should be trivial with nitro too π
It should, but sadly not for me so far. π€·ββοΈ
But will check out the Nitro docs- thanks for the pointer!