Khalil
Khalil
CCConvex Community
Created by Khalil on 7/29/2024 in #support-community
Is there a recommended way to use Convex on "admin mode"
I have setup an "apiKey" in the args for mutations, query and actions that i want to protect, but it seems a bit hacky. Wondering if there is another recommended approach? Something similar to the firebase or supabase admin client would be really nice IMO
10 replies
CCConvex Community
Created by Khalil on 7/11/2024 in #support-community
vector search stopped working
My code has not changed for a few weeks, and now the vector search method inside actions is no longer returning results when using the filter property.
15 replies
CCConvex Community
Created by Khalil on 6/9/2024 in #support-community
Pupppeteer/Playwright?
Is there a suggested approach for using Convex to perform web-scrapping or at least orchestrate the pipeline?
2 replies
CCConvex Community
Created by Khalil on 5/14/2024 in #support-community
Convex+Clerk: sign out unhandled runtime error
Hi Convex team, I've been battling this issue for a couple of weeks and have no idea what to try anymore. I have the latest versions of everything: Clerk, Convex, Nextjs For Convex, I combine RSC and client components, using fetchQuery for RSC and of course useQuery and useMutation on the client. I setup everything according to both, Clerk and Convex documentation in the middleware.ts I have:
// middleware.ts

import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";
import { NextResponse } from "next/server";

const isProtectedRoute = createRouteMatcher(["/projects(.*)", "/waitlist(.*)"]);

export default clerkMiddleware((auth, req) => {
const signInUrl = new URL("/sign-in", req.url).toString();
if (isProtectedRoute(req)) {
auth().protect({ unauthenticatedUrl: signInUrl });
}

return NextResponse.next();
});

export const config = {
matcher: [
// Exclude files with a "." followed by an extension, which are typically static files.
// Exclude files in the _next directory, which are Next.js internals.
"/((?!.+\\.[\\w]+$|_next|monitoring).*)",
// Re-include any files in the api or trpc folders that might have an extension
"/(api|trpc)(.*)",
],
};
// middleware.ts

import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server";
import { NextResponse } from "next/server";

const isProtectedRoute = createRouteMatcher(["/projects(.*)", "/waitlist(.*)"]);

export default clerkMiddleware((auth, req) => {
const signInUrl = new URL("/sign-in", req.url).toString();
if (isProtectedRoute(req)) {
auth().protect({ unauthenticatedUrl: signInUrl });
}

return NextResponse.next();
});

export const config = {
matcher: [
// Exclude files with a "." followed by an extension, which are typically static files.
// Exclude files in the _next directory, which are Next.js internals.
"/((?!.+\\.[\\w]+$|_next|monitoring).*)",
// Re-include any files in the api or trpc folders that might have an extension
"/(api|trpc)(.*)",
],
};
in my authed layout I have:
<ClerkLoaded>
<Authenticated>{children}</Authenticated>
<Unauthenticated>
<RedirectToSignIn />
</Unauthenticated>
</ClerkLoaded>
<ClerkLoading>
<Loading />
</ClerkLoading>
<ClerkLoaded>
<Authenticated>{children}</Authenticated>
<Unauthenticated>
<RedirectToSignIn />
</Unauthenticated>
</ClerkLoaded>
<ClerkLoading>
<Loading />
</ClerkLoading>
And I return null for all queries, when ctx.auth.getUserIdentity() is null. The problem happens when I logout, the app just crashes with an "unhandled runtime error"
// browser console logs
clerk.browser.js:2 Uncaught (in promise) Error
at o._fetch (clerk.browser.js:2:80700)
at async ne.create (clerk.browser.js:2:118896)
// browser console logs
clerk.browser.js:2 Uncaught (in promise) Error
at o._fetch (clerk.browser.js:2:80700)
at async ne.create (clerk.browser.js:2:118896)
This is also happening on production
34 replies
CCConvex Community
Created by Khalil on 4/23/2024 in #support-community
Getting Convex error on Clerk Signout
When I signout I get an error (although signout does work). I am using @clerk/nextjs 5.0.1 and convex 1.11.2
{
"errors": [
{
"message": "Signed out",
"long_message": "You are signed out",
"code": "signed_out"
}
],
"clerk_trace_id": "ac6972ae4b580468505a88fd465abac2"
}
{
"errors": [
{
"message": "Signed out",
"long_message": "You are signed out",
"code": "signed_out"
}
],
"clerk_trace_id": "ac6972ae4b580468505a88fd465abac2"
}
6 replies
CCConvex Community
Created by Khalil on 4/9/2024 in #support-community
recommendations for storing data used for analytics in Convex?
Hey Convex team, I am building a chat interface that will be storing thousands of records used for analytics, and this data will be queried, aggregated, etc. by month ranges (april, may, june, etc.). What is the recommended pseudo-schema for storing these kind of data in Convex? I am afraid to create an individual record for each record as I would in postgres
7 replies
CCConvex Community
Created by Khalil on 4/4/2024 in #support-community
Clerk JWT Template additional properties
No description
3 replies
CCConvex Community
Created by Khalil on 3/31/2024 in #support-community
Best practices for writing DB queries/mutations
I am currently migrating my backend from trpc + prisma to Convex and trying to understand the best practices in terms of writing secure and scalable software with the platform. My understanding is that every mutation/query/action/http endpoints that I write is exposed to the world, and it's my job to write the logic inside the handler to prevent actions from malicious users? I currently have a mutation like so:
export const remove = mutation({
args: {
orgId: v.string(),
},
handler: async (ctx, args) => {
await ctx.db.delete(resource._id);
return null;
},
});
export const remove = mutation({
args: {
orgId: v.string(),
},
handler: async (ctx, args) => {
await ctx.db.delete(resource._id);
return null;
},
});
I want to use this mutation both inside an HTTP function that is triggered via webhooks from Clerk, and also inside the webapp for authenticated users. What would be the best way to secure such mutations that are shared between webhooks and user sessions?
6 replies
CCConvex Community
Created by Khalil on 3/27/2024 in #support-community
Using Hono for HTTP in Convex issues with SSE
I am trying to make use of Hono's first class support for SSE https://hono.dev/helpers/streaming but Convex returns 502 (bad gateway). Is this not support by the platform?
11 replies