Skip to content

Commit

Permalink
add function
Browse files Browse the repository at this point in the history
  • Loading branch information
georg-stone committed Oct 2, 2024
1 parent 6a8f3ae commit fe5227a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/app/api/fetchFeed/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// route.js

export async function GET(req) {
const { searchParams } = new URL(req.url);
const url = searchParams.get("url");

if (!url) {
return new Response('Missing "url" parameter', { status: 400 });
}

try {
const response = await fetch(url);

if (!response.ok) {
return new Response("Failed to fetch the URL", {
status: response.status,
});
}

const text = await response.text();
return new Response(text, {
headers: {
"Content-Type": response.headers.get("Content-Type"),
},
});
} catch (error) {
return new Response("Error fetching the URL", { status: 500 });
}
}

0 comments on commit fe5227a

Please sign in to comment.