popcornguy
popcornguy
Explore posts from servers
CCConvex Community
Created by popcornguy on 5/19/2024 in #support-community
Error while using Plunk with Convex
No description
13 replies
CCConvex Community
Created by popcornguy on 5/11/2024 in #support-community
Convex ents v.optional() makes user Value | undefined
No description
84 replies
CCConvex Community
Created by popcornguy 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 popcornguy 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 popcornguy 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 popcornguy 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 popcornguy 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 popcornguy on 5/6/2024 in #support-community
Weird type issues
No description
7 replies
TTCTheo's Typesafe Cult
Created by popcornguy on 5/3/2024 in #questions
Best fully typesafe, fully managed, headless CMS with a generous free tier for Next.js 14.
Hi, what headless CMSes do you like/recommend the most? I recently tried Sanity and did not like it that much as it lacks typesafety so I tried using @sanity-typed with it which improved the DX a whole lot and added typesafety, but it turns out that the Sanity studio does not play very nicely with @sanity-typed. I am looking for a headless CMS, which is fully typesafe, has a premade dashboard to manage content and has a generous free tier. Santiy checked nearly all of these boxes but the lack of proper typesafety was a no go for me. I was thinking about Payload CMS, but it requires me to host a separate express server AFAIK. So I looked into Payload 3.0 Beta which looks great, fully Next.js native - wow exactly what I wanted and I only need to host the db, seems like a no brainer for me, Tho, I do not want to use Beta software and I would really hate starting with V2 and then just shortly after migrate to V3. I would also highly appriciate if the CMS to worked with Cloudinary.
2 replies
TtRPC
Created by popcornguy on 5/2/2024 in #❓-help
How to disable Next.js draftmode in tRPC?
Hi guys, is it possible to disable the Next.js draft mode using tRPC? I am tryin to achieve something such as this:
import { draftMode } from 'next/headers';
import { NextRequest, NextResponse } from 'next/server';

export function GET(request: NextRequest) {
draftMode().disable();
const url = new URL(request.nextUrl);
return NextResponse.redirect(new URL('/', url.origin));
}
import { draftMode } from 'next/headers';
import { NextRequest, NextResponse } from 'next/server';

export function GET(request: NextRequest) {
draftMode().disable();
const url = new URL(request.nextUrl);
return NextResponse.redirect(new URL('/', url.origin));
}
But with tRPC, I tried calling draftMode().disable(); in my tRPC function but nothing happened, draftMode did not get disabled.
2 replies
PPrisma
Created by popcornguy on 4/24/2024 in #help-and-questions
Prisma not working on middleware even tho the app is being ran on a server.
Hi guys, I keep getting this error when using Prisma with Next.js 14 app, I plan to run my app on a server in a docker container so not edge runtime will be used, but I keep getting this:
[Error: PrismaClient is not configured to run in Vercel Edge Functions or Edge Middleware. In order to run Prisma Client on edge runtime, either:
- Use Prisma Accelerate: https://pris.ly/d/accelerate
- Use Driver Adapters: https://pris.ly/d/driver-adapters

If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report]
[Error: PrismaClient is not configured to run in Vercel Edge Functions or Edge Middleware. In order to run Prisma Client on edge runtime, either:
- Use Prisma Accelerate: https://pris.ly/d/accelerate
- Use Driver Adapters: https://pris.ly/d/driver-adapters

If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report]
How should I fix this error?
2 replies