Skip to content

Commit

Permalink
Merge pull request #278 from TeamRecorDream/add-277-cors
Browse files Browse the repository at this point in the history
[add] cors
  • Loading branch information
Seokyeong237 authored May 26, 2024
2 parents c5cede7 + 8aea5fd commit 9ce68d5
Show file tree
Hide file tree
Showing 4 changed files with 4,805 additions and 5,691 deletions.
54 changes: 48 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^4.17.13",
"@types/jest": "^28.1.6",
"@types/jsonwebtoken": "^8.5.9",
Expand Down Expand Up @@ -46,6 +47,7 @@
"aws-sdk": "^2.1171.0",
"axios": "^0.27.2",
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dayjs": "^1.11.3",
"dotenv": "^16.0.1",
"ejs": "^3.1.8",
Expand Down
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import express, { Request, Response, NextFunction } from "express";
const app = express();
import connectDB from "./loaders/db";
import routes from "./routes";
import swaggerUi from "swagger-ui-express";
import YAML from "yamljs";
import path from "path";
import cors from "cors";
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("dotenv").config();

const app = express();
connectDB();

app.use(express.urlencoded({ extended: true }));
app.use(express.json());

const whitelist = ["https://recordream-web.vercel.app", "http://localhost:5173"];
const corsOptions: cors.CorsOptions = {
origin: whitelist,
credentials: true,
optionsSuccessStatus: 200,
};

app.use(cors(corsOptions));

app.use(routes); //라우터
// error handler
const swaggerSpec = YAML.load(path.join(__dirname, "../build/swagger.yaml"));
Expand Down
Loading

0 comments on commit 9ce68d5

Please sign in to comment.