nextjs-shopify-app
nextjs-shopify-app copied to clipboard
Question about the `afterAuth` signature
Hi @t-kelly !
First of all, great work! I really enjoy looking at that serverless Shopify App example and learned a lot from it. :)
I have a question about the code below.
https://github.com/t-kelly/nextjs-shopify-app/blob/1e61d7acc7ced6545484b35c4f59c4bd9fee8801/lib/shopify.js#L76-L78
To my understanding, the goal here is to retrieve a new redirectUrl
value returned from the afterAuth
promise. If this value is a truthy (a non-empty string, in that case), we assign it to redirectUrl
. Else we simply use the original redirectUrl
value.
However, after reading the afterAuth
promise, I see that it doesn't return anything (Promise<void>
) and only do side effects. Because of that, the condition will simply always keep the same value for redirectUrl
.
https://github.com/t-kelly/nextjs-shopify-app/blob/1e61d7acc7ced6545484b35c4f59c4bd9fee8801/pages/api/auth/%5B...shopify%5D.js#L4-L27
So, I'm not sure. Did I misunderstood something or it is not the researched effect?
Hey @arsnl - since the return value is optional i assume the afterAuth method has multiple purposes.
- overwrite the default redirectUrl
- be a hook for you to store the session, update context, register a webhook etc. etc.
It's ages since you asked and might not be that useful now - i just stumbled upon you're question :)