Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Node: redirect after post webhook

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 343

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