Current Project Architecture
- Nuxt 2 App (v2.15.8)
- ssr is set on true (default)
- built with target static
- using runtimeConfigs for dynamic deployment with different URLs of the Backend
- CI/CD create server-specific .env and "generates" the app via
nuxt generate
The Goal
I got the task, we should be able to change the Backend Url after the app is built.
This is because our PM would be able to copy the Server Deployed Master and use it for presentations on a separate demo instance (or on dynamic customer side presentations) therefore, he won't want to trigger a new deployment, "just to change the API URL".
Try´N`Error
Use configurable JSON in assets folder
- this wasn't a good idea, since webpack puts it into js chunks > so, not easy editable for the PM
Could I exclude a File from Webpack to bundle it?, did not find a working solution
Use configurable JSON in static folder
- easy to configure for the PM
- but at build timeJSONxt reads the json fiea lds, but it into store or call the file inside a plugin, (I thinJSONxt knows the json is in the static folder and therefore it assumes, this file will not change) > so it put the value of the JSON inside json in every component, so I can't change it anymore
- I can change the JSON inside the json, but nothing changes in the code, since the build step "hardcoded" it
using .env on the server
As far as I know, the static files do not have access to the env variables, and we do not run a nodeJs server on our app hosting server.
So currently I have no Idea to solve this NuxtJs is a nice Framework and I use it for many years, but this problem gives me a headache.
Just to mention, our PM argument is, "in our other app,..." (which is built with angular) "... it is 'easy' possible"
He is right, in this app, we have a JSON, which is loaded in runtime. So is there a way to build this in nuxt?