Skip to content

Commit

Permalink
Merge pull request #5 from Prakharnagore/cors
Browse files Browse the repository at this point in the history
add cors
  • Loading branch information
Prakharnagore committed Jul 27, 2024
2 parents 42acc5e + 9d7a4a7 commit dcb9c17
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ DB_PASSWORD=
DB_NAME=
REFRESH_TOKEN_SECRET=
JWKS_URI=
PRIVATE_KEY=
PRIVATE_KEY=
ADMIN_DASHBOARD_URL=
23 changes: 23 additions & 0 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 @@ -24,6 +24,7 @@
"@types/bcrypt": "^5.0.1",
"@types/bcryptjs": "^2.4.6",
"@types/cookie-parser": "^1.4.7",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/express-validator": "^3.0.0",
"@types/http-errors": "^2.0.4",
Expand Down Expand Up @@ -57,6 +58,7 @@
"dependencies": {
"bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.1",
"express-jwt": "^7.7.8",
Expand Down
9 changes: 8 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import "reflect-metadata";

import cors from "cors";
import express, { Request, Response, NextFunction } from "express";
import cookieParser from "cookie-parser";
import logger from "./config/logger";
import { HttpError } from "http-errors";
import authRouter from "./routes/auth";
import tenantRouter from "./routes/tenant";
import userRouter from "./routes/user";
import { Config } from "./config";

const app = express();
app.use(
cors({
origin: [Config.ADMIN_DASHBOARD_URL!],
credentials: true,
}),
);
app.use(express.static("public"));
app.use(cookieParser());
app.use(express.json());
Expand Down
2 changes: 2 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {
REFRESH_TOKEN_SECRET,
JWKS_URI,
PRIVATE_KEY,
ADMIN_DASHBOARD_URL,
} = process.env;

export const Config = {
Expand All @@ -29,4 +30,5 @@ export const Config = {
REFRESH_TOKEN_SECRET,
JWKS_URI,
PRIVATE_KEY,
ADMIN_DASHBOARD_URL,
};

0 comments on commit dcb9c17

Please sign in to comment.