Created
November 4, 2025 21:00
-
-
Save herveguetin/1bf585574dd9381d209ec2287fb75c63 to your computer and use it in GitHub Desktop.
Shopify • Market-safe post-login redirect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const makeLoginRedirectUrl = (path = ""): string => { | |
| const currentUrl = new URL(window.location.href); | |
| const basePath = Shopify.routes.root.replace(/\/$/, ""); | |
| const returnPath = path || `${currentUrl.pathname}${currentUrl.search}`.replace(basePath, ""); | |
| const returnTo = `${basePath}/${returnPath}`.replace(/\/{2,}/g, "/"); | |
| return `${currentUrl.origin}/customer_authentication/login?return_to=${encodeURIComponent(returnTo)}`; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment