Skip to content

Commit

Permalink
updated header options
Browse files Browse the repository at this point in the history
  • Loading branch information
jazicorn committed Oct 5, 2023
1 parent 794bf8c commit f583e9e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions apps/api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ class App {

constructor(authControllers, controllers) {
// #TODO | figure out how to turn env var string to an array of strings
this.corsOptions = [
"https://vercel.com/jazicorn/recodecamp-web",
"https://recodecamp-web.vercel.app",
"https://www.recodecamp.com"
];
console.log(this.corsOptions)
this.corsOptions = '';
this.app = express();
this.port = parseInt(process.env.PORT as string) || 8000;
this.initMiddlewares();
Expand All @@ -44,12 +39,20 @@ class App {
this.app.use(cookieParser());
this.app.options("*", (req, res) => {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "PUT, PATCH, POST, GET, DELETE, OPTIONS");
res.setHeader("Access-Control-Allow-Methods", "GET, HEAD, PUT, PATCH, POST, DELETE, OPTIONS");
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
res.sendStatus(204);
});
this.app.use(cors({
origin: this.corsOptions
origin: [
"https://vercel.com/jazicorn/recodecamp-web",
"https://recodecamp-web.vercel.app",
"https://recodecamp-web.vercel.app/#/",
"https://www.recodecamp.com"
],
"methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
"preflightContinue": false,
"optionsSuccessStatus": 204
}));
// this.app.use( "/", (req, res, next) => {
// res.setHeader('access-control-allow-origin', '*');
Expand Down

0 comments on commit f583e9e

Please sign in to comment.