File tree 1 file changed +6
-4
lines changed
apps/studio/src/app/api/v1/crawler
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ export async function GET(request: NextRequest) {
8
8
const Base64searchParams = request . nextUrl . searchParams . get ( 'base64' ) ;
9
9
const URLsearchParams = request . nextUrl . searchParams . get ( 'url' ) ;
10
10
11
+ const invalidResponse = new NextResponse ( 'Not a valid URL' , { status : 500 } ) ;
11
12
try {
12
13
if ( ! Base64searchParams && ! URLsearchParams ) return new NextResponse ( null , { status : 200 } ) ;
13
14
let info : DocumentInfo | null = null ;
@@ -23,10 +24,10 @@ export async function GET(request: NextRequest) {
23
24
if ( response . status === 200 ) {
24
25
info = await parseURL ( response . data ) ;
25
26
} else {
26
- return new NextResponse ( 'Not a valid URL' , { status : 500 } ) ;
27
+ return invalidResponse ;
27
28
}
28
29
} catch ( error ) {
29
- return new NextResponse ( 'Not a valid URL' , { status : 500 } ) ;
30
+ return invalidResponse ;
30
31
}
31
32
}
32
33
@@ -90,14 +91,15 @@ export async function GET(request: NextRequest) {
90
91
</head>
91
92
</html>
92
93
` ;
93
- console . log ( crawlerInfo ) ;
94
+
94
95
return new NextResponse ( crawlerInfo , {
95
96
status : 200 ,
96
97
headers : {
97
98
'Content-Type' : 'text/html' ,
98
99
} ,
99
100
} ) ;
100
101
} catch ( err ) {
101
- return new NextResponse ( 'Not a valid URL' , { status : 500 } ) ;
102
+ return invalidResponse ;
102
103
}
103
104
}
105
+
You can’t perform that action at this time.
0 commit comments