Skip to content

Commit 22aafc7

Browse files
committed
Fix timeout issue
1 parent 812066f commit 22aafc7

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/app/api/image/route.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { NEXT_AUTH_CONFIG } from "@/utils/auth";
33
import { getServerSession } from "next-auth";
44
import { NextRequest, NextResponse } from "next/server";
55

6+
export const maxDuration = 60;
7+
68
export async function POST(req: NextRequest) {
79
const session = await getServerSession(NEXT_AUTH_CONFIG);
810
if (!session) {
@@ -42,7 +44,7 @@ export async function POST(req: NextRequest) {
4244
seed: randomSeed,
4345
userId: user.id,
4446
},
45-
});
47+
});
4648

4749
return NextResponse.json({ url: imageUrl })
4850
}

src/app/generate-image/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export default function Page() {
4848
});
4949

5050
async function onSubmit(values: z.infer<typeof formSchema>) {
51+
if (!session) {
52+
toast({ variant: "destructive", description: "Login required to generate an image." });
53+
return;
54+
}
5155
try {
5256
setLoading(true);
5357
const response = await fetch("/api/image", {
@@ -106,7 +110,7 @@ export default function Page() {
106110
containerClassName="rounded-full"
107111
as="button"
108112
buttonType={btnType.submit}
109-
btnDisabled={loading || !session}
113+
btnDisabled={loading}
110114
className="disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50
111115
bg-black text-white flex items-center space-x-2 w-full md:w-auto">
112116
<span className="flex justify-center items-center gap-2 w-auto">

vercel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"functions": {
3-
"src/app/api/image/generate/route.ts": {
3+
"app/api/**/*": {
44
"maxDuration": 60
55
}
66
}

0 commit comments

Comments
 (0)