Title pretty much sums it up. I've got a proxy.conf.js file that gets hit on ng serve and I just want to grab the target url from the environment ts file, or a json file, or I don't really care at this point, I just want one place to store the URL that feeds the others respectively...
So environment.dev.ts;
export const environment = {
production: false,
apiUrl: 'http://localhost:12345'
};
Then proxy.conf.js;
var settings = require('./src/environments/environment.dev');
const PROXY_CONFIG = [{
"/restapi/*": {
"target": settings.environment.apiUrl,
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
}
}]
module.exports = PROXY_CONFIG
Which for some reason I obviously don't understand (especially since intellisense fills in the path just fine for both the file and the property) I get error on ng serve;
Cannot find module './src/environments/environment.dev'
Error: Cannot find module './src/environments/environment.dev'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
........
So my question is, why can it not resolve this way? I just want one file to set the target URL on that feeds the places it's needed from environment.dev.ts
from Use environment to set proxy.config.js property for ng serve
No comments:
Post a Comment