Reputation: 21
I have this code in envrionment.ts
export const environment = {
production: false,
host_name: 'http://local.website.com',
api_name: 'http://local.website.com/api',
ajax_name: 'http://local.website.com/ajax',
};
Once the app is built, we need to change the environment settings without undergoing another build. Essentially because the web-app is coupled to another website, and the back-end people want to change these settings without running a build. Using the .env root file has been ruled-out as insecure leaving a .json file in the assets folder as the only option. There is another ts file on the app that can read the json with no problem when served but envrionment.ts can not seem to, supposedly because its static. Any help would be appreciated.
Upvotes: 1
Views: 3042
Reputation: 555
At the company I work for now, they adjust the settings via ftp. For this reason, it needs to read the json file and rewrite it every time the client is refreshed.
Follow the instructions in the url I shared. it worked for us.
Edit : maybe you can use specifically created regex records.
You can try changing it in main.bundle.js
using the fs library belonging to nodejs. like this
export const environment = {
production: '<<<<PRODUCTION>>>>',
host_name: '<<<<HOST_NAME>>>>',
api_name: '<<<<API_NAME>>>>',
ajax_name: '<<<<AJAX_NAME>>>>',
};
Upvotes: 1