diff --git a/src/components/SignInPage/SignInPage.tsx b/src/components/SignInPage/SignInPage.tsx index 02b899d32..b2a0626f1 100644 --- a/src/components/SignInPage/SignInPage.tsx +++ b/src/components/SignInPage/SignInPage.tsx @@ -14,7 +14,9 @@ export default class SignInPage extends React.PureComponent { handleRedirectToAuthDapp = () => { if (this.props.isAuthDappEnabled && !this.props.isConnected && !this.props.isConnecting) { - redirectToAuthDapp() + const params = new URLSearchParams(window.location.search) + const basename = /^decentraland.(zone|org|today)$/.test(window.location.host) ? '/builder' : '' + redirectToAuthDapp(`${basename}${params.get('redirectTo') || '/'}`) } } diff --git a/src/routing/locations.ts b/src/routing/locations.ts index fdcb6dcfe..aeb9f4f4f 100644 --- a/src/routing/locations.ts +++ b/src/routing/locations.ts @@ -53,6 +53,8 @@ export const locations = { templateDetail: (templateId = ':templateId') => `/templates/${templateId}` } -export function redirectToAuthDapp() { - window.location.replace(`${config.get('AUTH_URL')}/login?redirectTo=${encodeURIComponent(window.location.href)}`) +export function redirectToAuthDapp(customRedirect?: string) { + window.location.replace( + `${config.get('AUTH_URL')}/login?redirectTo=${encodeURIComponent(customRedirect ? customRedirect : window.location.href)}` + ) }