refactored function name. added environment variable. removed rewrite of host header as this only apply in some debug use cases ((will require some refactoring so these cases are still handled somehow moving forward)