Skip to content

Commit

Permalink
fix: update cors (11)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafirm29 committed Aug 16, 2022
1 parent 79b779c commit 90f0a1b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@ import * as cors from 'cors';

const app = express();

app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header(
'Access-Control-Allow-Methods',
'GET,HEAD,PUT,POST,OPTIONS,UPDATE,DELETE'
);
res.header(
'Access-Control-Allow-Headers',
'Origin, X-Requested-With, Content-Type, Accept, Authorization, token'
);
next();
});

app.use(
cors({
origin: 'https://preview-social.katitb22.com',
origin: '*',
credentials: true,
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
})
Expand All @@ -30,7 +43,7 @@ const httpServer = createServer(app);

const io = new Server(httpServer, {
cors: {
origin: 'https://preview-social.katitb22.com',
origin: '*',
credentials: true,
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
},
Expand Down

0 comments on commit 90f0a1b

Please sign in to comment.