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 61d3900 commit 5918197
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/api/backend.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ import ProjectNameModel from './schema.mjs'; // Import your Mongoose model

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

// Configure CORS to allow your frontend
// Middleware setup
app.use(cors(corsOptions));

app.use(express.json()); // Parse JSON bodies

// Handle OPTIONS request (Preflight request)
app.options('*', cors(corsOptions)); // For all routes
const corsOptions = {
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)
credentials: true, // Optional: allow cookies or authentication
};

app.use(cors(corsOptions)); // Use CORS with the options
app.use(express.json()); // Parse JSON requests

// MongoDB connection
const mongoUrl = "mongodb+srv://leviron:[email protected]/BlockScanDB?retryWrites=true&w=majority&appName=BlockScan";
mongoose
Expand Down

0 comments on commit 5918197

Please sign in to comment.