cornpopguy
cornpopguy
CCConvex Community
Created by cornpopguy on 5/19/2024 in #support-community
Error while using Plunk with Convex
No description
13 replies
CCConvex Community
Created by cornpopguy on 5/11/2024 in #support-community
Convex ents v.optional() makes user Value | undefined
No description
84 replies
CCConvex Community
Created by cornpopguy on 5/9/2024 in #support-community
Error related to jsx-email ✘ [ERROR] Could not resolve "path"
No description
9 replies
CCConvex Community
Created by cornpopguy on 5/8/2024 in #support-community
Is it possible to retrieve the `UserIdenity` based on its subject?
Hi guys, Is it possible to retrieve the UserIdenity based on its subject, if so how?
17 replies
CCConvex Community
Created by cornpopguy on 5/8/2024 in #support-community
How can I use Convex in the Next.js middleware?
I am trying to use Convex in my middleware like so, but ctx.auth.getUserIdentity() in my action keeps returning null, I believe that this is due it running on the server so it is not wrapped with <ConvexProviderWithClerk />:
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
import { fetchAction } from 'convex/nextjs';
import { NextResponse } from 'next/server';

import { api } from '@/convex/_generated/api';
import { env } from '@/env';

const isPrivateRoute = createRouteMatcher([`${env.NEXT_PUBLIC_AFTER_AUTH_REDIRECT_URL}(.*)`]);
const isAuthRoute = createRouteMatcher([
`${env.NEXT_PUBLIC_CLERK_SIGN_IN_URL}(.*)`,
`${env.NEXT_PUBLIC_CLERK_SIGN_UP_URL}(.*)`,
]);

export default clerkMiddleware(async (auth, req) => {
const { url } = req;
const user = await fetchAction(api.clerk.user.getUserInfo);
console.log(user.user.stripeUserId);

if (isAuthRoute(req)) {
return NextResponse.redirect(new URL(env.NEXT_PUBLIC_AFTER_AUTH_REDIRECT_URL, url));
} else if (isPrivateRoute(req)) {
auth().protect();
return auth().redirectToSignIn();
}

return NextResponse.next();
});

export const config = {
matcher: [
'/((?!.*\\..*|_next).*)', // Don't run middleware on static files
'/', // Run middleware on index page
'/(api|trpc)(.*)', // Run middleware on API routes
],
};
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
import { fetchAction } from 'convex/nextjs';
import { NextResponse } from 'next/server';

import { api } from '@/convex/_generated/api';
import { env } from '@/env';

const isPrivateRoute = createRouteMatcher([`${env.NEXT_PUBLIC_AFTER_AUTH_REDIRECT_URL}(.*)`]);
const isAuthRoute = createRouteMatcher([
`${env.NEXT_PUBLIC_CLERK_SIGN_IN_URL}(.*)`,
`${env.NEXT_PUBLIC_CLERK_SIGN_UP_URL}(.*)`,
]);

export default clerkMiddleware(async (auth, req) => {
const { url } = req;
const user = await fetchAction(api.clerk.user.getUserInfo);
console.log(user.user.stripeUserId);

if (isAuthRoute(req)) {
return NextResponse.redirect(new URL(env.NEXT_PUBLIC_AFTER_AUTH_REDIRECT_URL, url));
} else if (isPrivateRoute(req)) {
auth().protect();
return auth().redirectToSignIn();
}

return NextResponse.next();
});

export const config = {
matcher: [
'/((?!.*\\..*|_next).*)', // Don't run middleware on static files
'/', // Run middleware on index page
'/(api|trpc)(.*)', // Run middleware on API routes
],
};
7 replies
CCConvex Community
Created by cornpopguy on 5/8/2024 in #support-community
What is the recommended way of syncing users with Clerk?
Hi guys! My current setup of doing this is to mostly use the UserIdentity object to retrive user data. But I also have some additional information alongside the info from UserIndentity about the users such as the Stripe Customer Id. So I listen for Clerk webhook events such as 'user.created', 'user.updated' and 'user.deleted' to reflect this for the Stripe Customers. So I basically just store the additional information in the db along with the Clerk user id. Is this the proper/recommended way of doing so? What is the recommended / best way of syncing users with Clerk?
2 replies
CCConvex Community
Created by cornpopguy on 5/7/2024 in #support-community
Is it possible to automatically sync auth identity without webhooks
Is it possible to automatically sync auth identity without webhooks for Clerk? Like listen for some events on Auth Identity changes or are webhooks the only option?
5 replies
CCConvex Community
Created by cornpopguy on 5/6/2024 in #support-community
Weird type issues
No description
7 replies