Elliott-Chong/chatpdf-yt

Clerk blocking /api/stripe

mikenems opened this issue · 1 comments

To reproduce:

  1. click upgrade to pro

  2. enter details into stripe

  3. all succeeds on the stripe side and returns to "/"

  4. However Clerk seems to be blocking access to /api/stripe with the following error:
    [401] POST http://localhost:3000/api/stripe
    Also, the following logs are sent from Clerk:
    INFO: Clerk: The request to /api/stripe is being protected (401) because there is no signed-in user, and the path is included in apiRoutes. To prevent this behavior, choose one of:

  5. To prevent Clerk authentication from protecting (401) the api route, remove the rule matching "/api/stripe" from the apiRoutes array passed to authMiddleware

  6. To make the route accessible to both signed in and signed out users, add "/api/stripe" to the publicRoutes array passed to authMiddleware

  7. To prevent Clerk authentication from running at all, pass ignoredRoutes: ["/((?!api|trpc))(_next.*|.+\.[\w]+$)", "/api/stripe"] to authMiddleware

  8. Pass a custom afterAuth to authMiddleware, and replace Clerk's default behavior of redirecting unless a route is included in publicRoutes

I am logged in.

Also, I've tried adding /api/stripe to the public_routes in middleware but it then returns 405 Method Not Allowed

I've tried updating the library for clerk again as well.

I'm stuck with what to debug next.

Thanks!

For additional information about middleware, please visit https://clerk.com/docs/nextjs/middleware

Nope! Nevermind - this was my mistake.

When setting up the Stripe CLI I modifed the listen command incorrectly. I was pointing to /api/stripe instead of /api/webhook!