File tree Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import { NEXT_AUTH_CONFIG } from "@/utils/auth";
33import { getServerSession } from "next-auth" ;
44import { NextRequest , NextResponse } from "next/server" ;
55
6+ export const maxDuration = 60 ;
7+
68export 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}
Original file line number Diff line number Diff 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" >
Original file line number Diff line number Diff line change 11{
22 "functions" : {
3- "src/ app/api/image/generate/route.ts " : {
3+ "app/api/**/* " : {
44 "maxDuration" : 60
55 }
66 }
You can’t perform that action at this time.
0 commit comments