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 2536533 commit b59884d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
16 changes: 14 additions & 2 deletions app/api/backend.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,21 @@ import ProjectNameModel from './schema.mjs'; // Import your Mongoose model

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

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

const corsOptions = {
origin: function (origin, callback) {
if (allowedOrigins.indexOf(origin) !== -1 || !origin) {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
}
},
};

app.use(cors(corsOptions)); // Use CORS with the options
app.use(express.json()); // Parse JSON requests
app.use(cors({ origin: '*' })); // Enable CORS for all origins

// MongoDB connection
const mongoUrl = "mongodb+srv://leviron:[email protected]/BlockScanDB?retryWrites=true&w=majority&appName=BlockScan";
Expand Down
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
"name": "my-next-app",
"version": "0.1.0",
"private": true,

"scripts": {
"dev": "npx concurrently \"npm:dev-frontend\" \"npm:dev-backend\"",
"dev-frontend": "next dev",
"dev-backend": "node app/api/backend.mjs",
"build": "next build",
"start": "next start",
"lint": "next lint"
},

"dev": "npx concurrently \"npm:dev-frontend\" \"npm:dev-backend\"",
"dev-frontend": "next dev",
"dev-backend": "node app/api/backend.mjs",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-icons": "^1.3.0",
Expand Down

0 comments on commit b59884d

Please sign in to comment.