The code in Viewport uses LoginUriProvider.getLoginUri() - a service from Atlassian Shared Access Layer (SAL) - and sets the value returned from that call as the redirect target. There seems to be a bug in at least some versions of Confluence SAL plugin. The code here ( https://bitbucket.org/atlassian/atlassian-sal/src/275619451fef2331a18689e37c8c6b0e79d7bcbd/sal-core/src/main/java/com/atlassian/sal/core/auth/SeraphLoginUriProvider.java#lines-49 ) does not take into account that the login url can be absolute, but always prepends the base path.
Viewport should have a workaround in place in order to avoid this bug in Confluence.