Thanks @munner for replaying.
After doing some tests, including assigning the URL with plain text (and not from a variable) just reliased that that variable was not being assigned after login in. A silly mistake that took me couple of days to find.
Thanks once again.