Mightsrain
Possible to update API path in static build without rebuild.
Hello,
I have a where we are distributing a static build nuxt app in a python package to provide a frontend similar to MLflow. The package can host a python api that the nuxt frontend relies on. So currently I set the the api path in
nuxt.config.ts
in runtimeConfig.public
so that the path is available to all pages within the frontend. The frontend is hosted statically also though python using fastapi.
The problem I am running into is that once the frontend is built, that api path is set and I cannot find a way to be able to update it without rebuilding the frontend. I would like to avoid having to rebuild the frontend if possible in order to avoid requiring users to have node setup on their machine in order to update the api path.
I have scoured the docs to find a way and see several notes implying it is not possible, for example on the .env
page it notes, Note that for a purely static site, it is not possible to set runtime configuration config after your project is prerendered.
.
Is anyone aware of a way that it would be possible to update a global variable to be used by the static site?
My current best solution that I have come up with involves rebuilding the app within a docker container each time that the user starts it up and then using volumes to copy it out and then statically host it. But hopefully could find a cleaner way.
Thank you in advance.13 replies