File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1+ import { NextResponse } from 'next/server' ;
2+
3+ export async function GET ( ) {
4+ try {
5+ const apiBaseUrl = process . env . SHORTENED_BASE_URL ;
6+ if ( ! apiBaseUrl ) {
7+ throw new Error ( 'API_BASE_URL not configured' ) ;
8+ }
9+ const pingResponse = await fetch ( `${ apiBaseUrl } /ping` ) ;
10+ const data = await pingResponse . json ( ) ;
11+ if ( data . status === 'ok' ) {
12+ return NextResponse . json ( { ready : true } , { status : 200 } ) ;
13+ }
14+ } catch ( error : any ) {
15+ return NextResponse . json ( { error : error . message } , { status : 400 } ) ;
16+ }
17+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export async function POST(request: NextRequest) {
1212 const shortenedBaseUrl = process . env . SHORTENED_BASE_URL ;
1313
1414 if ( ! shortenedBaseUrl ) {
15- throw new Error ( 'SHORTENED_BASE_URL not configured' ) ;
15+ throw new Error ( 'API_BASE_URL not configured' ) ;
1616 }
1717 const shortenedUrl = await createShortenUrl ( url , shortenedBaseUrl ) ;
1818 return NextResponse . json ( { shortenedUrl } , { status : 200 } ) ;
You can’t perform that action at this time.
0 commit comments