-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61d3900
commit 5918197
Showing
1 changed file
with
8 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|