KeyCloak redirects to wrong port when using custom protocol

Hello,

Backstory: I’m trying to set up authentication with react-native/expo on android but i keep getting redirected back to the wrong port. In order to get android to trigger launch of the expo app I’m using the protocol exp://. I want to be redirected to exp://127.0.0.1:19000 but i get redirected to exp://127.0.0.1

Problem:
KeyCloak removes the port from the redirect.
I get a login link that looks like:
https:///auth/realms/master/protocol/openid-connect/auth?code_challenge=&code_challenge_method=S256&prompt=login&redirect_uri=exp%3A%2F%2F127.0.0.1%3A19000%2F–%2Fexpo-auth-session&client_id=demo&response_type=code&state=RbRhWBBjQg&scope=openid%20profile%20%20email%20%20api

I’m expecting to be redirected to exp://127.0.0.1:19000 but i keep getting redirected to exp://127.0.0.1:80. If i change the protocol from exp to http it works (given that I add them to Valid Redirect URIs)

I get redirected to something like: exp://127.0.0.1/–/expo-auth-session?state=RbRhWBBjQg&session_state=93bf4fd9-29fb-438b-8ec1-a5a150ed82ad&code=e46643c8-13f6-4964-b23f-85144735b579.93bf4fd9-29fb-438b-8ec1-a5a150ed82ad.3568fb9b-9dfa-434c-a68d-45fbf711becc
Notice the port missing here!

This can be replicated by adding any redirect with dummy protocol and a port. Try to log in anch check network tab in browser developer tools.

Does anybody have any ideas?

Are you using expo auth session?

Yes. I can get around the problem by using the Expo proxy, but i don’t really want to use the proxy.