Passing username and password for upstream service with url rewrite

Am using just the tyk-gateway community edition and executing an url_rewrite in my API which seem to work as per the logs. The rewrite_to url is composed perfect, but upon execution the api fails with authentication. What is the best way to configure/pass “upstream” basic authentication credentials in this case?

I also tried to write a virtual endpoint, however it gets timed out in 5s and thus fails.

Is there a better way to achieve this?

Also, is there any preference for executing both url_rewrites and virtual endpoint in the same API definition? It looks like the virtual endpoint overrides the “url_rewrites” in my case.