#arshia_webhooks-redirect

1 messages ยท Page 1 of 1 (latest)

brazen frostBOT
#

๐Ÿ‘‹ 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.

whole plover
#

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

winged tusk
#

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?

whole plover
#

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

winged tusk
#

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

whole plover
#

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?

winged tusk
#

I haven't done that can you share how? I'm new to coding so it's my first time using webhooks.

whole plover
#

curl -X POST <your server URL> -d '{}' for example in your terminal to try and simulate a post request to your server

winged tusk
#

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 }); }

whole plover
#

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?

winged tusk
whole plover
#

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

winged tusk
#

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

brazen frostBOT
winged tusk
#

We're good! It's working now ๐Ÿ™Œ

#

Thank you