aftabrehan / jarvis-ai

Complete AI Tools (Chatbot, Image Generation, Music Generation, Video Generation, and Code Generation) SaaS Platform built using Next.js 14, Stripe, OpenAI, ReplicateAI, Crisp, Aiven, and Prisma.
https://jarvis-wex.vercel.app
MIT License
19 stars 9 forks source link

Events after the payement process for pro plan #1

Open Vaibhav-nk-git opened 6 months ago

Vaibhav-nk-git commented 6 months ago

after successful payement for the pro plan its redirecting to /settings and there is no plan update

this is what im getting

INFO: Clerk: The request to /webhook 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:

  1. To prevent Clerk authentication from protecting (401) the api route, remove the rule matching "/webhook" from the apiRoutes array passed to authMiddleware
  2. To make the route accessible to both signed in and signed out users, add "/webhook" to the publicRoutes array passed to authMiddleware
  3. To prevent Clerk authentication from running at all, pass ignoredRoutes: ["/((?!api|trpc))(_next.*|.+\.[\w]+$)", "/webhook"] to authMiddleware
  4. Pass a custom afterAuth to authMiddleware, and replace Clerk's default behavior of redirecting unless a route is included in publicRoutes

For additional information about middleware, please visit https://clerk.com/docs/nextjs/middleware (This log only appears in development mode, or if debug: true is passed to authMiddleware)

And my gpt says

It looks like you're receiving multiple log messages indicating that the request to "/webhook" is being protected (401) because there is no signed-in user, and the path is included in apiRoutes. This typically indicates an issue with authentication middleware configuration, specifically with Clerk authentication.

Here are some possible solutions based on the provided log messages:

Remove "/webhook" from apiRoutes: If you don't want the "/webhook" route to be protected by Clerk authentication, you can remove it from the apiRoutes array passed to the authMiddleware. Add "/webhook" to publicRoutes: If you want the "/webhook" route to be accessible to both signed-in and signed-out users, you can add it to the publicRoutes array passed to the authMiddleware. Ignore "/webhook" route for authentication: If you want to prevent Clerk authentication from running at all for the "/webhook" route, you can pass ignoredRoutes: ["/webhook"] to the authMiddleware configuration. Customize afterAuth behavior: You can pass a custom afterAuth function to the authMiddleware and replace Clerk's default behavior of redirecting unless a route is included in publicRoutes. Choose the solution that best fits your authentication requirements and modify your middleware configuration accordingly. Make sure to test your changes to ensure that the authentication behavior is as expected.

aftabrehan commented 6 months ago

@Vaibhav-nk-git, Please, take a look at this video. This is how it was working for me the last time I checked. No new changes have been made.

Anyway, I'll take a look whenever I get the chance. Big thanks for notifying me. Would you like to checkout my other latest projects?

aftabrehan commented 6 months ago

P.S. The api/webhook is already being considered as the public route. So that might not be the root of this issue.

https://github.com/aftabrehan/jarvis-ai/blob/f591e39468013d6ce55c0a8adea95c6a20191e08/middleware.ts#L4