How do I set OktaCallbackComponent redirect with sign-in widget

I have an Angular application that I am converting the Okta hosted login to an internally hosted login using the Okta Sign-In Widget.

The authentication login redirect route implements the OktaCallbackComponent. Whch according to the docs redirects to / for a non-protected route. Or, from what I see looking at the source code for OktaAuthService loginRedirect(‘path’) sets a referrerPath in Session Storage that gets redirected to after authentication.

So previously with the Okta hosted login I was calling OktaAuthService.loginRedirect('myPath') which successfully redirected to myPath after authentication.

Now my app hosted login component that loads the widget is routed from …/login. When I land on that page and after the widget is loaded ‘login’ has been stored in referrerPath which results in a redirect back to the path /login after the CallbackComponent redirects.

My question is how do I set the value that is stored in referrerPath like was done when calling loginRedirect?

I’ve implemented a workaround via explicitly setting sessionStorage.setItem('referrerPath', 'mypath'); in onAuthRequired. I feel like there should be a better way to handle via the Okta api’s though.