Node: redirect after post webhook

davydovct
Shopify Partner
18 0 2

How can i redirect user to a specific page after getting webhook data?

 

This doesn't work:

router.post('/webhooks/customers/create', webhook, (ctx) => {

   /* handle customers create */
  console.log('received webhook: ', ctx.state.webhook);
if (ctx.request.body.email == 'bad_email@email.org') {
ctx.status = 301;
ctx.redirect('/wrong_email.html');
}

 

Reply 1 (1)

Alex
Shopify Staff
1561 81 341

Webhook requests are made from our back end to communicate resource changes to your back end. There won't be a user attached to these requests, so the redirect would only serve to have our back end interpret the 300 range status as a failed delivery, prompting a retry. You're expected to always return to webhook requests with a 200 range request to imply a successful delivery.

 

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog