Skip to content

Commit

Permalink
Merge pull request #50 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 95617ea + b445055 commit 9ff5ee4
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions apps/api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,23 @@ class App {
this.app.use(bodyParser.json());
this.app.use(cookieParser());
this.app.use(cors({
origin: this.corsOptions
origin: this.corsOptions,
credentials : true,
methods: 'GET,PUT,POST,DELETE,OPTIONS',
allowedHeaders: 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
}));
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");
res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
next();
});
this.app.options("/", (req, res) => {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "PUT, POST, GET, DELETE, OPTIONS");
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
res.sendStatus(204);
});
// 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");
// res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
// next();
// });
// this.app.options("/", (req, res) => {
// res.setHeader("Access-Control-Allow-Origin", "*");
// res.setHeader("Access-Control-Allow-Methods", "PUT, POST, GET, DELETE, OPTIONS");
// res.setHeader("Access-Control-Allow-Headers", "Content-Type");
// res.sendStatus(204);
// });
// this.app.set('trust proxy', 1) // trust first proxy
// this.app.use(session({
// secret: process.env.SECRET_TOKEN,
Expand Down

1 comment on commit 9ff5ee4

@vercel
Copy link

@vercel vercel bot commented on 9ff5ee4 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.vercel.app
recodecamp-api-git-main-jazicorn.vercel.app
recodecamp-api-jazicorn.vercel.app

Please sign in to comment.