Oren
Oren
CCConvex Community
Created by Josh | Fanpool on 9/7/2024 in #support-community
Logs do not work
make sure to check logs in convex dashboard -> dev instance
3 replies
CCConvex Community
Created by sanjeev bhusal on 9/2/2024 in #support-community
Issue with nodemailer
hey I was looking for the same solution the default Email provider will not work but I use custom http email provider as sshader recommended like this
{
id: "http-email",
name: "Email",
type: "email",
maxAge: 60 * 60 * 24, // Email link will expire in 24 hours
//@ts-expect-error -- `ctx` argument is missing in types
sendVerificationRequest: async ({ identifier, url }, ctx) => {
await ctx.runAction(internal.email.sendVerificationEmail, {
to: identifier,
url,
});
},
},
{
id: "http-email",
name: "Email",
type: "email",
maxAge: 60 * 60 * 24, // Email link will expire in 24 hours
//@ts-expect-error -- `ctx` argument is missing in types
sendVerificationRequest: async ({ identifier, url }, ctx) => {
await ctx.runAction(internal.email.sendVerificationEmail, {
to: identifier,
url,
});
},
},
11 replies
CCConvex Community
Created by Oren on 9/1/2024 in #support-community
convex auth causes browser "leave site?" prompt on every redirect e.g. stripe or auth
gotta have it matching inclusive of
/api
/api
8 replies
CCConvex Community
Created by Oren on 9/1/2024 in #support-community
convex auth causes browser "leave site?" prompt on every redirect e.g. stripe or auth
it has something to do with middleware route matcher when I use matcher as only this it causes problem (recommended from nextjs docs)
"/((?!_next/static|_next/image|api|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)"
"/((?!_next/static|_next/image|api|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)"
If I use it like this including convex auth recommended matcher the problem goes away
"/((?!_next/static|_next/image|api|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
"/",
"/(api|trpc)(.*)",
"/((?!_next/static|_next/image|api|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
"/",
"/(api|trpc)(.*)",
🤔
8 replies
CCConvex Community
Created by Oren on 9/1/2024 in #support-community
convex auth causes browser "leave site?" prompt on every redirect e.g. stripe or auth
this also happens when I click on oauth button
"use client";

import { useEffect } from "react";
import { useAuthActions } from "@convex-dev/auth/react";

import { routes } from "@/lib/utils";
import { Button } from "@/components/ui/button";

interface OauthButtonProps {
provider: "google";
icon: React.ReactNode;
text: string;
isLoading: boolean;
isDisabled: boolean;
setLoading: (state: boolean) => void;
}

export const OauthButton = ({
provider,
icon,
isDisabled,
setLoading,
isLoading,
text,
}: OauthButtonProps) => {
const { signIn } = useAuthActions();

useEffect(() => {
return () => setLoading?.(false);
}, [setLoading]);

return (
<Button
variant="outline"
isLoading={isLoading}
disabled={isDisabled}
onClick={async (event) => {
event.preventDefault();
event.stopPropagation();
setLoading(true);

await signIn(provider, {
redirectTo: `${window.location.origin}/${routes.app.imagine}`,
});
}}
>
<div className="flex items-center pr-3">{icon}</div>
<span className="">{text}</span>
</Button>
);
};
"use client";

import { useEffect } from "react";
import { useAuthActions } from "@convex-dev/auth/react";

import { routes } from "@/lib/utils";
import { Button } from "@/components/ui/button";

interface OauthButtonProps {
provider: "google";
icon: React.ReactNode;
text: string;
isLoading: boolean;
isDisabled: boolean;
setLoading: (state: boolean) => void;
}

export const OauthButton = ({
provider,
icon,
isDisabled,
setLoading,
isLoading,
text,
}: OauthButtonProps) => {
const { signIn } = useAuthActions();

useEffect(() => {
return () => setLoading?.(false);
}, [setLoading]);

return (
<Button
variant="outline"
isLoading={isLoading}
disabled={isDisabled}
onClick={async (event) => {
event.preventDefault();
event.stopPropagation();
setLoading(true);

await signIn(provider, {
redirectTo: `${window.location.origin}/${routes.app.imagine}`,
});
}}
>
<div className="flex items-center pr-3">{icon}</div>
<span className="">{text}</span>
</Button>
);
};
8 replies
CCConvex Community
Created by Oren on 9/1/2024 in #support-community
convex auth causes browser "leave site?" prompt on every redirect e.g. stripe or auth
this is what happens when I click the button
onClick={async () => {
setPriceIdLoading(price.id);

if (token) {
try {
const { data: url } = await createCheckoutSession({
priceId: annual ? price.yearlyId! : price.id!,
});

if (!url) {
return;
} else {
window.location.assign(url);
}
} catch (error) {
console.error(error);
toast.error("Error creating checkout session");
}
} else {
router.push(routes.app.settings);
}
}}
onClick={async () => {
setPriceIdLoading(price.id);

if (token) {
try {
const { data: url } = await createCheckoutSession({
priceId: annual ? price.yearlyId! : price.id!,
});

if (!url) {
return;
} else {
window.location.assign(url);
}
} catch (error) {
console.error(error);
toast.error("Error creating checkout session");
}
} else {
router.push(routes.app.settings);
}
}}
and this is the createCheckoutSession action
export const createCheckoutSession = action({
args: { priceId: v.string() },
handler: async (ctx, { priceId }) => {
const stripe = new Stripe(process.env.STRIPE_KEY!, {
apiVersion: "2024-06-20",
});

const { data: user } = await ctx.runQuery(api.users.getCurrentUser);

let customer = user?.stripe_customer_id ?? null;

if (!user) {
return { data: null, error: "Not authenticated" };
}

if (!user.stripe_customer_id) {
... some logic
}

if (!customer) {
return { data: null, error: "No customer found" };
}

const session = (await stripe.checkout.sessions.create({
... some logic
})) as Stripe.Checkout.Session;

return { data: session.url };
},
});
export const createCheckoutSession = action({
args: { priceId: v.string() },
handler: async (ctx, { priceId }) => {
const stripe = new Stripe(process.env.STRIPE_KEY!, {
apiVersion: "2024-06-20",
});

const { data: user } = await ctx.runQuery(api.users.getCurrentUser);

let customer = user?.stripe_customer_id ?? null;

if (!user) {
return { data: null, error: "Not authenticated" };
}

if (!user.stripe_customer_id) {
... some logic
}

if (!customer) {
return { data: null, error: "No customer found" };
}

const session = (await stripe.checkout.sessions.create({
... some logic
})) as Stripe.Checkout.Session;

return { data: session.url };
},
});
8 replies
CCConvex Community
Created by Oren on 9/1/2024 in #support-community
convex auth causes browser "leave site?" prompt on every redirect e.g. stripe or auth
hmm the url comes from convex mutation but I would think as I have the url and it triggers redirect the mutation would be complete 🤔 I will give the debug a try thank you
8 replies
CCConvex Community
Created by Oren on 8/22/2024 in #support-community
how to use authRateLimits?
ty michal will take a look 💪
3 replies
CCConvex Community
Created by Oren on 8/21/2024 in #support-community
sentry errors
No description
10 replies
CCConvex Community
Created by Oren on 8/21/2024 in #support-community
sentry errors
No description
10 replies
CCConvex Community
Created by Oren on 8/21/2024 in #support-community
sentry errors
[POST] [middleware: "middleware"] /api/auth reason=EDGE_FUNCTION_INVOCATION_FAILED, status=500, user_error=true
10 replies
CCConvex Community
Created by Oren on 8/21/2024 in #support-community
sentry errors
this is what I found in vercel logs for the server error Error: [Request ID: d8c3063dfae98371] Server Error at (node_modules/.pnpm/convex@1.14.1_react-dom@18.3.1_react@18.3.1react@18.3.1/node_modules/convex/dist/esm/browser/http_client.js:323:0) at (node_modules/.pnpm/@convex-dev+auth@0.0.57_convex@1.14.1_react-dom@18.3.1_react@18.3.1react@18.3.1next@14.2._iqy6brgeee4fbt5oz57gluz3we/node_modules/@convex-dev/auth/dist/nextjs/server/proxy.js:28:0) at (node_modules/.pnpm/@convex-dev+auth@0.0.57_convex@1.14.1_react-dom@18.3.1_react@18.3.1react@18.3.1next@14.2._iqy6brgeee4fbt5oz57gluz3we/node_modules/@convex-dev/auth/dist/nextjs/server/index.js:49:0) at (nodemodules/.pnpm/@sentry+nextjs@8.26.0@opentelemetry+api@1.9.0@opentelemetry+core@1.25.1@opentelemetry+api@_ksey7zpx5z6xea4jmy5iongufm/node_modules/@sentry/nextjs/build/esm/common/utils/edgeWrapperUtils.js:49:0) at (nodemodules/.pnpm/next@14.2.5@babel+core@7.25.2_@opentelemetry+api@1.9.0_react-dom@18.3.1_react@18.3.1react@18.3.1/node_modules/next/dist/esm/server/web/adapter.js:158:0)
10 replies
CCConvex Community
Created by kstulgys on 8/9/2024 in #support-community
I use convex auth with nextjs setup, but userId always null
13 replies
CCConvex Community
Created by kstulgys on 8/9/2024 in #support-community
I use convex auth with nextjs setup, but userId always null
yeap make sure to set the auth env vars or run the automated script and it should work 👍
13 replies
CCConvex Community
Created by kstulgys on 8/9/2024 in #support-community
I use convex auth with nextjs setup, but userId always null
try
const sermons = await fetchQuery(api.tasks.getTasks, {}, {
token: convexAuthNextjsToken(),
});
const sermons = await fetchQuery(api.tasks.getTasks, {}, {
token: convexAuthNextjsToken(),
});
13 replies
CCConvex Community
Created by Oren on 8/21/2024 in #support-community
sentry errors
No description
10 replies
CCConvex Community
Created by kstulgys on 8/9/2024 in #support-community
I use convex auth with nextjs setup, but userId always null
how do you call the authQuery? if its from serverside you should pass token as the 3rd param
13 replies
CCConvex Community
Created by Oren on 8/4/2024 in #support-community
using zod schema for validation
ty
16 replies
CCConvex Community
Created by Ferdinand on 8/17/2024 in #support-community
AuthSessions and AuthRefreshTokens not deleted after signOut
thank you works now 👍
10 replies
CCConvex Community
Created by Ferdinand on 8/17/2024 in #support-community
AuthSessions and AuthRefreshTokens not deleted after signOut
@Ferdinand I see I have the same problem how did you solve it?
10 replies