@phychem_ad You can expose the environmental variable from AEM and based on that you can handle the requests in ui,frontend module.
Something similar to below:
@Component(
service = { Servlet.class },
property = {
Constants.SERVICE_DESCRIPTION + "=Environment Variables Servlet",
"sling.servlet.paths=/bin/environment/variables",
"sling.servlet.methods=GET"
}
)
public class EnvironmentVariablesServlet extends SlingSafeMethodsServlet {
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {
response.setContentType("application/json");
response.getWriter().write("{ \"apiUrl\": \"" + System.getenv("API_URL") + "\" }");
}
}