Skip to content

Commit

Permalink
Merge pull request #68 from jazicorn/dev
Browse files Browse the repository at this point in the history
updated header options
  • Loading branch information
jazicorn authored Oct 5, 2023
2 parents 8a55a0e + 85ba56c commit ecffa6a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions apps/api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ class App {
"preflightContinue": false,
"optionsSuccessStatus": 204
}));
this.app.use( "/", (req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
res.setHeader('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
next();
});
// this.app.use( "/", (req, res, next) => {
// res.setHeader('Access-Control-Allow-Origin', '*');
// res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
// res.setHeader('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
// next();
// });
// this.app.set('trust proxy', 1) // trust first proxy
// this.app.use(session({
// secret: process.env.SECRET_TOKEN,
Expand All @@ -77,7 +77,14 @@ class App {

private initControllers(controllers) {
controllers.forEach((controller) => {
this.app.use('/', controller.router);
this.app.use('/', (req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
res.setHeader('Access-Control-Allow-Methods', 'GET, PUT, PATCH, POST, DELETE');
next();
},
controller.router
);
});
}

Expand Down

1 comment on commit ecffa6a

@vercel
Copy link

@vercel vercel bot commented on ecffa6a Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

recodecamp-api – ./apps/api

recodecamp-api-git-main-jazicorn.vercel.app
recodecamp-api-jazicorn.vercel.app
recodecamp-api.vercel.app

Please sign in to comment.