I’m trying to utilize a directory structure name to pass to webhook nodejs code and do something with it.
Here’s my POC:
webhook.m.pipedream.net/
props: {
path: {type: "string"}
},
async run({ steps, $ }) {
//crop leading slash
let path = this.path.split("/")[1]
console.log(path)
if (path === "") {
await $.respond({
status: 200,
body: "You've landed on the root of the domain",
})
}
} else {
await $.respond({
status: 200,
body: path,
})
}
My problem is that my webhook gets called twice on any path other than “/”. First time for that path, and immediately redirects to the root. So, if I enter:
webhook.m.pipedream.net/hello
the webhook gets called twice, first time for hello and then for “/”, and “You’ve landed on the root of the domain” is served. I never see the “hello” in my browser.
I’ve tried various permutations of the following code:
await $.respond({
status: 302,
redirect: "manual", // doesn't seem to make any difference
headers: {
"Location": "/report" // this gets me into an infinite loop
},
body: body_of_report,
})
Please advise,
Thank you,