Clerk blocking /api/stripe
mikenems opened this issue · 1 comments
To reproduce:
-
click upgrade to pro
-
enter details into stripe
-
all succeeds on the stripe side and returns to "/"
-
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 inapiRoutes
. To prevent this behavior, choose one of: -
To prevent Clerk authentication from protecting (401) the api route, remove the rule matching "/api/stripe" from the
apiRoutes
array passed to authMiddleware -
To make the route accessible to both signed in and signed out users, add "/api/stripe" to the
publicRoutes
array passed to authMiddleware -
To prevent Clerk authentication from running at all, pass
ignoredRoutes: ["/((?!api|trpc))(_next.*|.+\.[\w]+$)", "/api/stripe"]
to authMiddleware -
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!