-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (25 loc) · 1.09 KB
/
server.js
File metadata and controls
30 lines (25 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import cookieParser from "cookie-parser";
import auth_router from "./api/user_system/AuthRoute.js";
import authRoute from "./api/user_system/AuthRoute.js";
import express from "express";
import cors from "cors";
import recipe_posts_router from "./api/recipe_posts/route.js";
import user_info_router from "./api/user_info/route.js";
import followers_info_router from "./api/followers/followersRoute.js";
import following_info_router from "./api/following/followingRoute.js";
const app = express();
const corsOptions = {
origin: "https://social-cookbook-frontend.vercel.app/", // The exact origin of the frontend
credentials: true, // This allows the server to accept cookies from the frontend
};
app.use(cors());
app.use(express.json());
app.use(cookieParser());
app.use("/", authRoute);
app.use("/api/auth", auth_router);
app.use("/api/recipe-posts", recipe_posts_router);
app.use("/api/followers", followers_info_router);
app.use("/api/following", following_info_router);
app.use("/api/users", user_info_router);
app.use("*", (req, res) => res.status(404).json({ error: "not found" }));
export default app;