feat: CORS setup

This commit is contained in:
karishmas6
2024-04-12 12:24:41 +05:30
parent 11c40fae6c
commit c77608d6d6

View File

@@ -1,5 +1,11 @@
const fastify = require('fastify')();
const scraper = require('./scraper');
// Change this later
const corsOptions = {
origin: 'http://localhost:5173'
}
fastify.register(require('@fastify/cors'), corsOptions)
fastify.post('/scrape', async (request, reply) => {
const { url, selections } = request.body;
@@ -16,5 +22,5 @@ fastify.post('/scrape', async (request, reply) => {
fastify.listen(3000, (err, address) => {
if (err) throw err;
console.log(`Server is now listening on ${address}`);
console.log(`Server listening on ${fastify.server.address().port}`)
});