diff --git a/app/api/metadata/proxy/feature/ip.ts b/app/api/metadata/proxy/feature/ip.ts index f9fe5cedd..4573a3636 100644 --- a/app/api/metadata/proxy/feature/ip.ts +++ b/app/api/metadata/proxy/feature/ip.ts @@ -90,7 +90,7 @@ export async function checkURLForPrivateIP(uri: URL | string) { for (const address of addresses) { if (isPrivateIP(address.address)) { return true; - } + } } } else { const singleResult = addresses as unknown as LookupAddressResult; diff --git a/app/api/metadata/proxy/route.ts b/app/api/metadata/proxy/route.ts index 965e3a136..90b7951c8 100644 --- a/app/api/metadata/proxy/route.ts +++ b/app/api/metadata/proxy/route.ts @@ -18,7 +18,7 @@ const TIMEOUT = process.env.NEXT_PUBLIC_METADATA_TIMEOUT /** * Respond with error in a JSON format */ -function respondWithError(status: keyof typeof errors, message?: string){ +function respondWithError(status: keyof typeof errors, message?: string) { return NextResponse.json({ error: message ?? errors[status].message }, { status }); } @@ -47,14 +47,17 @@ export async function GET( // check that uri has supported protocol despite of any other checks if (!isHTTPProtocol(parsedUrl)) { + console.error('Unsupported protocol', parsedUrl.protocol); return respondWithError(400); } const isPrivate = await checkURLForPrivateIP(parsedUrl); if (isPrivate) { + console.error('Private IP detected', parsedUrl.hostname); return respondWithError(403); } } catch (_error) { + console.error(_error); return respondWithError(400); }