Error : Moved Permanently POST /api/kinde-webhook 400
Hi, I'm currently trying to implement a Webhook with Kinde in order to sync The Kinde Users with my DynamoDB database.
I used this command for dev testing :
I changed the URL Webhook in Kinde to the URL generated by nGrok. With that tool I can see the JWT but I encountered this error : Moved Permanently POST /api/kinde-webhook 400. And I have no idea what's wrong...
Here's my api/kinde-webhook/route.ts file.
10 Replies
Here's the Webhook setting in Kinde

Hi Hundrick,
Thanks for the detailed info and screenshots, that really helps.
https://6b1681308703.ngrok-free.app/api/kinde-webhook
Based on this and the error
Observations: 1. Webhook Path Looks Correct
Your endpoint URL in the Kinde dashboard matches the ngrok URL +
The “Moved Permanently” error (likely HTTP 308) usually indicates a redirect , often caused by: - A missing trailing slash in the request when the framework expects one (or vice versa). - Misconfigured route file in the App Router. 3. 400 Bad Request
Your handler returns 400 when the JWT is invalid or verification fails, which may be expected if the request is being redirected or malformed before reaching your logic.
Thanks for the detailed info and screenshots, that really helps.
https://6b1681308703.ngrok-free.app/api/kinde-webhook
Based on this and the error
Moved Permanently POST /api/kinde-webhook 400
, here’s a quick analysis and some next steps:Observations: 1. Webhook Path Looks Correct
Your endpoint URL in the Kinde dashboard matches the ngrok URL +
/api/kinde-webhook
, which looks good.
2. Next.js App Routing Issue PossibleThe “Moved Permanently” error (likely HTTP 308) usually indicates a redirect , often caused by: - A missing trailing slash in the request when the framework expects one (or vice versa). - Misconfigured route file in the App Router. 3. 400 Bad Request
Your handler returns 400 when the JWT is invalid or verification fails, which may be expected if the request is being redirected or malformed before reaching your logic.
1. Recommendations:
1. Test with a Minimal Handler
To confirm your webhook is even hitting the endpoint (before decoding JWT), temporarily replace your handler with:
Then trigger the webhook again via the “Send test event” in the Kinde UI and check your terminal logs.
2. Check File Placement and Server Running
Ensure:
- The
route.ts
is located exactly at:app/api/kinde-webhook/route.ts
(not pages/api
)
- Your dev server is running locally via npm run dev
or yarn dev
.
- The ngrok tunnel is started after your local server is running.
3. Try with Trailing Slash
Some frameworks treat /api/kinde-webhook
and /api/kinde-webhook/
differently.
You can try updating the Kinde webhook URL to:
Sometimes this prevents an implicit redirect (HTTP 308) that Next.js might trigger depending on the route handler config.
4. Ensure No Middleware/Auth on Webhook Path
Confirm that the /api/kinde-webhook
route is not protected by any middleware, authentication wrapper, or headers check. Kinde must be able to call this route unauthenticated.
We’re attempting to replicate this setup internally as well. While we do that, feel free to:
- Replace the handler with a minimal logging version.
- Test triggering the webhook via the UI.
- Let us know if you see "Webhook received"
in your terminal, that will confirm if the request is reaching your code or being redirected before it hits.
Thanks again for your patience while we dig into this!Kinde docs
Add and manage webhooks
Our developer tools provide everything you need to get started with Kinde.
1. Test with a Minimal Handler : the console log and the NextResponse.json work great. ✅
2.Check File Placement and Server Running ✅
3.Try with Trailing Slash : Kinde won't let me do that, the "/" at the end is an error for him. ❌
4. Ensure No Middleware/Auth on Webhook Path : I already allowed api/kinde-webhook as a public route as you can see ✅
It's seems that the issue is inside my logic
Because the solution 1 works

It seems that the error comes from this line
But this ligne comes from your documentation : https://docs.kinde.com/integrate/webhooks/webhooks-nextjs/
Is the code outdated ?
Kinde docs
Set up webhooks using Next.js
Our developer tools provide everything you need to get started with Kinde.
Oh I found the error it's so stupid...
I wrote
instead of
So here the code wasn't happy :
Thank you help and your time !
Hi Hundrick,
You're absolutely welcome, and no worries at all! That trailing slash mistake is super easy to miss, especially when working with environment variables and URL construction. Glad you caught it , great debugging!
You're absolutely welcome, and no worries at all! That trailing slash mistake is super easy to miss, especially when working with environment variables and URL construction. Glad you caught it , great debugging!