diff --git a/scraper/src/main.js b/scraper/src/main.js index c5e93417..2829715e 100644 --- a/scraper/src/main.js +++ b/scraper/src/main.js @@ -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;