Skip to content

Commit

Permalink
try cors differently
Browse files Browse the repository at this point in the history
  • Loading branch information
rugglcon committed Aug 25, 2019
1 parent 341f2f7 commit 7af8f0d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
10 changes: 2 additions & 8 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@ class App {
}

config(): void {
this.app.use(cors({
origin: true,
credentials: true
}));
this.app.options('*', cors({
origin: true,
credentials: true
}));
this.app.use(cors());
this.app.options('*', cors());
this.app.use((_req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
Expand Down
2 changes: 1 addition & 1 deletion src/routes/budget.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const budgetRoutes = (appCors: (options?: cors.CorsOptions | cors.CorsOpt
budgetLogic: BudgetLogic, expenseLogic: ExpenseLogic): Router => {
const budgetsRouter = Router();

budgetsRouter.all('*', appCors({ origin: true, credentials: true }));
// budgetsRouter.all('*', appCors({ origin: true, credentials: true }));

// validates that id is a number
budgetsRouter.param('id', (_req, res, next, id) => {
Expand Down
8 changes: 4 additions & 4 deletions src/routes/expense.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export const expenseRoutes = (appCors: (options?: cors.CorsOptions | cors.CorsOp
}
});

expensesRouter.all('*', appCors({
origin: true,
credentials: true
}));
// expensesRouter.all('*', appCors({
// origin: true,
// credentials: true
// }));

// creates an expense
expensesRouter.post('/', async (req, res) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/user.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const userRoutes = (appCors: (options?: cors.CorsOptions | cors.CorsOptio
}
});

userRouter.all('*', appCors({ origin: true, credentials: true }));
// userRouter.all('*', appCors({ origin: true, credentials: true }));

// logs a user in
userRouter.post(
Expand Down

0 comments on commit 7af8f0d

Please sign in to comment.