T
TanStack•6mo ago
metropolitan-bronze

Load a static file in top-level directory dynamically with environment variables

I have a file that I need to store in my top-level .well-known that needs to have some values changed within it based on environment variables. I tried using API routes to serve this file, but I can not have it prefixed by /api for this to work. Is there a way to add on a Nitro handler for this behavior? I have been looking through questions, closest thing I have seen is for dynamic values for a Content Security Policy but nothing on explicitly serving a JSON file that has dynamically changing keys.
4 Replies
fascinating-indigo
fascinating-indigo•6mo ago
on the alpha version you can place ServerRoutes (formerly known as API Routes) anyhwere in the route tree you are not restricted to the /api prefix anymore
metropolitan-bronze
metropolitan-bronzeOP•6mo ago
Do you know when this feature will be off the alpha tag?
fascinating-indigo
fascinating-indigo•6mo ago
hopefully soon 😉 we got a few things to fix before that still
ambitious-aqua
ambitious-aqua•6mo ago
I don't think this is documented yet (might be wrong) but you achieve it like this in the alpha build
No description

Did you find this page helpful?