0

I am running 2 NodeJS servers. One serves the angular-ui-router front-end. The other serves the data. I run them both by giving the same command in two different directories: node server.js

So I have the two server.js files, plus the app.js file for the front-end (with the urls/states) and an index.js file for the back-end (with the urls/endpoints).

I'd like to configure them to use either http or https.

This means adding a flag in each server-js file, as well as changing the module.constant declarations in the app-js file.

Is there a way for the code in the app-js file to access something declared in the front-end server-js file? Or do I always need to change 3 files to switch between http and https?

Laurel
  • 5,965
  • 14
  • 31
  • 57
Randy Strauss
  • 93
  • 1
  • 7
  • So do you actualy require app.js in server.js? If so you can pass anything from server.js to app.js but it depends on how your app.js is structured. – Molda Jun 03 '16 at 20:24
  • You could also programatically detect the protocol in app-js. Or, if you're only accessing same-origin resources, the frontend JS will use the protocol of the page it's running on (I think). – colonelsanders Jun 03 '16 at 20:44
  • What if you used environment variables for the configuration or at least allow overrides from environment variables. http://stackoverflow.com/questions/4870328/how-to-read-environment-variable-in-node-js – tiblu Jun 03 '16 at 21:22
  • are you hosting it somewhere like heroku some other PAAS with an TLS terminator? – cheshirecatalyst Feb 25 '17 at 14:46

0 Answers0