Skip to content

Commit

Permalink
fixing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Levironexe committed Oct 17, 2024
1 parent b59884d commit 61d3900
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions app/api/backend.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ import ProjectNameModel from './schema.mjs'; // Import your Mongoose model

const app = express(); // Initialize Express app

// Allow specific origins (replace with your Vercel frontend URL)
const allowedOrigins = ['https://blockscan-swin.vercel.app'];

// Configure CORS to allow your frontend
const corsOptions = {
origin: function (origin, callback) {
if (allowedOrigins.indexOf(origin) !== -1 || !origin) {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
}
},
origin: 'https://blockscan-swin.vercel.app', // Your Vercel frontend URL
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true, // Allow credentials if needed (optional)
};

app.use(cors(corsOptions)); // Use CORS with the options
Expand Down

0 comments on commit 61d3900

Please sign in to comment.