#arshia_webhooks-redirect
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1276322981316137071
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hey @winged tusk the first step would be to clarify exactly what the issue is. You say "webhooks don't work" but that doesn't really tell us what the issue is
Ok sorry. Let me try better. I'm getting these issues on the webhook I setup which is a 308 (Permanent Redirect). I'm not sure why or relevant, but I noticed the vercel domain webhook was receiving all success responses. Does this help explain better what the issue is?
If you are getting a 308 it means something on your server is attempting to redirect us when we try to make an HTTP requests on your webhook endpoint's URL
So this is what you need to debug
arshia_webhooks-redirect
Yeah it's weird because I can't find where there is a redirect. I did also check my next.config.mjs which only has:
`/** @type {import('next').NextConfig} */
const nextConfig = {};
export default nextConfig;
`
And also my middleware, which has:
`import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";
const isProtectedRoute = createRouteMatcher(["/dashboard(.)", "/setting(.)"]);
export default clerkMiddleware((auth, req) => {
if (isProtectedRoute(req)) auth().protect();
});
export const config = {
matcher: [
// Skip Next.js internals and all static files, unless found in search params
"/((?!_next|[^?]\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).)",
// Always run for API routes
"/(api|trpc)(.*)",
],
};`
Is there anything I can provide that would help us investigate?
It's odd because the webhook that is working which was on vercel's domain didn't even have api/webhook in the url
Not really on my end. Like really the redirect comes from you/your server. It might be before your routes are even reached, maybe you have cloudflare or some other system in front
What happens when you just curl that URL yourself in the terminal? Do you get a 308 too?
I haven't done that can you share how? I'm new to coding so it's my first time using webhooks.
curl -X POST <your server URL> -d '{}' for example in your terminal to try and simulate a post request to your server
Response was Redirecting...
I feel this is probably a great indicator of what's going on but I'm teaching myself coding and not sure what to do with it. Any advice would be appreicated ๐
if helpful, when I access my url directly in the browser, I get the response Webhook endpoint is live in the browser which I setup using:
export async function GET() { return new Response('Webhook endpoint is live', { status: 200 }); }
Unfortunately I can't really know, it's really specific to your own server configuration. It might be well before your code is even run
There are thousands of ways to deploy a website so I have nothing to go on. When it redirects what URL does it go to?
Ok, I see. hmm I just used vercel. It doesn't seem like accessing the url directly is redirecting me: https://domain.com/api/webhook
Maybe it's taking me to https://www.domain.com/api/webhook
Which Google is removing the www. from... could that be the problem that I should just setup a new webhook using the www. ?
yeah that's a common issue where your server requires www. or the HTTPS instead of HTTP so it redirects
so likely a vercel setting you can turn off, or just add www. to your WebhookEndpoint's URL
Ah I see. Wow. I spent days on this ๐
Vercel recommended I redirect to www.
When I added my domain
So I'll just create a new webhook with that url and try again. I'll let you know how it goes
Thank you @whole plover