Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/pages/_api/api/payment-link/photo-stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ export async function GET(request: Request) {

if (result.status === 402) return result.challenge;

const res = await fetch("https://picsum.photos/1024/1024");
const imageUrl = res.url;
let imageUrl: string;
try {
const res = await fetch("https://picsum.photos/1024/1024");
if (!res.ok) throw new Error(`upstream responded ${res.status}`);
imageUrl = res.url;
} catch (error) {
console.error("[payment-link/photo-stripe] upstream fetch failed:", error);
return new Response("Failed to load photo from upstream", { status: 502 });
}

const html = `<!doctype html>
<html lang="en">
Expand Down
11 changes: 9 additions & 2 deletions src/pages/_api/api/payment-link/photo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ export async function GET(request: Request) {

if (result.status === 402) return result.challenge;

const res = await fetch("https://picsum.photos/1024/1024");
const imageUrl = res.url;
let imageUrl: string;
try {
const res = await fetch("https://picsum.photos/1024/1024");
if (!res.ok) throw new Error(`upstream responded ${res.status}`);
imageUrl = res.url;
} catch (error) {
console.error("[payment-link/photo] upstream fetch failed:", error);
return new Response("Failed to load photo from upstream", { status: 502 });
}

const html = `<!doctype html>
<html lang="en">
Expand Down
14 changes: 12 additions & 2 deletions src/pages/_api/api/photo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ export async function GET(request: Request) {

if (result.status === 402) return result.challenge;

const res = await fetch("https://picsum.photos/1024/1024");
const url = res.url;
let url: string;
try {
const res = await fetch("https://picsum.photos/1024/1024");
if (!res.ok) throw new Error(`upstream responded ${res.status}`);
url = res.url;
} catch (error) {
console.error("[photo] upstream fetch failed:", error);
return Response.json(
{ error: "Failed to load photo from upstream" },
{ status: 502 },
);
}

return result.withReceipt(Response.json({ url }));
}
14 changes: 12 additions & 2 deletions src/pages/_api/api/sessions/photo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ export async function GET(request: Request) {

if (result.status === 402) return result.challenge;

const res = await fetch("https://picsum.photos/200/200");
const url = res.url;
let url: string;
try {
const res = await fetch("https://picsum.photos/200/200");
if (!res.ok) throw new Error(`upstream responded ${res.status}`);
url = res.url;
} catch (error) {
console.error("[sessions/photo] upstream fetch failed:", error);
return Response.json(
{ error: "Failed to load photo from upstream" },
{ status: 502 },
);
}

return result.withReceipt(Response.json({ url }));
}