Skip to content

Commit

Permalink
rollback origin
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgehl3n committed Nov 19, 2023
1 parent 0416eb9 commit 23f00db
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ class Application {

private _setMiddlewares(): void {
this.express.use(cors({
origin: process.env.FRONTEND_URL,
credentials: true,
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
optionsSuccessStatus: 200
}));

this.express.use(function (req: any, res: any, next) {
res.header('Access-Control-Allow-Credentials', true);

const allowedOrigins = ['http://localhost', 'http://localhost:3000', process.env.FRONTEND_URL];
const origin = req.headers.origin;
if (allowedOrigins.includes(origin)) {
res.setHeader('Access-Control-Allow-Origin', origin);
}

res.header('Access-Control-Allow-Origin', req.headers.origin);
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Origin, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, X-Response-Time, X-PINGOTHER, X-CSRF-Token,Authorization');
Expand Down

0 comments on commit 23f00db

Please sign in to comment.