Duplicate of
This has nothing to do with discourse, Check the SSO provider settings, that’s what is supposed to redirect back to the referrer