Skip to content

Commit

Permalink
vercel.json file created for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
shivang21007 committed Sep 12, 2023
1 parent 882876a commit 7fa78ae
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
19 changes: 10 additions & 9 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ app.use(express.json());

// Middleware for handling CORS POLICY
// Option 1: Allow All Origins with Default of cors(*)
app.use(cors());
// app.use(cors());

// Option 2: Allow Custom Origins
// app.use(
// cors({
// origin: 'http://localhost:5173',
// methods: ['GET', 'POST', 'PUT', 'DELETE'],
// allowedHeaders: ['Content-Type'],
// })
// );
app.use(
cors({
origin: 'http://localhost:5173',
methods: ['GET', 'POST', 'PUT', 'DELETE'],
allowedHeaders: ['Content-Type'],
credentials: true
})
);

app.get("/", (request, response) => {
//console.log(request);
return response.status(234).send("Welcome To MERN Stack Tutorial");
return response.status(234).send("Welcome to Book Store App.");
});

app.use("/books", booksRoute);
Expand Down
15 changes: 15 additions & 0 deletions backend/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": 2,
"builds": [
{
"src": "index.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "index.js"
}
]
}

0 comments on commit 7fa78ae

Please sign in to comment.