I want to access my node.js server as service in microservice infrastructure. This means that if locally I can access node server services /root-path-to-service
. But after deploying to infrastructure in AWS it is accessed as /microservice-path/root-path-to-service
and app.use('/root-path-to-service', ...)
does not work anymore. How can I configure to work in both cases?
Provide the path as an environment variable. Then read it from there in Node using:
process.env.ENV_VARIABLE_NAME
This is standard microservice practice.