I have a storefront in Shopify, and one of the tabs is a nextjs app which is hosted with app proxy. I have everything working, and I am trying to support users who are unauthenticated with Shopify.
I can detect if they are not authenticated and show a notification with a “Click here to login” link. The problem is, it always takes them to the orders page after the login, not back to the route they were on when I initiated the flow. I have tried a number of solutions but nothing is working including. Below is the loginUrl I am using in my tag as the href. The behavior described happens after the user clicks on the anchor.
1.)
const loginUrl = <STOREFRONT_DOMAIN>/customer_authentication/redirect?return_to=${currentUrl};
This approach gets them to the login page, they login, and it takes them to the orders page, instead of to my “current URL” value.
2.)
const loginUrl = <STOREFRONT_DOMAIN>/customer_authentication/login?return_to=${currentUrl};
I found this URL on line for some liquid apps or whatnot, but when I use this I get a Bad Request message in the main page.
Any help would be greatly appreciated!