Fixed endpoint is undefined in sandbox when custom_endpoint is disabled

I have custom_endpoint setting disabled in my environment, which results in endpoint variable in the sandbox is overriden by string 'undefined', which results in 404 requests.
See attached patch to fix this.