简体   繁体   中英

node.js angular.js get port from config

In my root directory, I have a config.json file that contains the port that the web server should listen to. This makes it easier for anyone using the app, but I can't GET/POST without knowing the port.

I can't access the config.json file as it's in my root directory while the AngularJS controllers are in a deeper directory.

If your Angular app makes relative calls, it shouldn't need to be specified. If you can't make all relative calls, then create a route that supplies Angular config, and call that relatively.

使用相对 URL 或var full = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: '');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM