feat: proxy route

This commit is contained in:
karishmas6
2024-04-16 23:49:05 +05:30
parent 73c678774f
commit 48b36e974c

View File

@@ -9,6 +9,18 @@ const corsOptions = {
}
fastify.register(require('@fastify/cors'), corsOptions)
fastify.get('/proxy', async (request, reply) => {
const { url } = request.query;
try {
const response = await fetch(url);
const html = await response.text();
reply.type('text/html').send(html);
} catch (error) {
reply.status(500).send(`Error fetching website: ${error.message}`);
}
});
fastify.post('/scrape', async (request, reply) => {
const { url, selectors } = request.body;