Skip to content

Commit

Permalink
Merge pull request #56 from KATITB22/story/cors-and-logs
Browse files Browse the repository at this point in the history
fix: update cors (11)
  • Loading branch information
rafirm29 authored Aug 16, 2022
2 parents 5893fa5 + 90f0a1b commit 510ed96
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 510ed96

Please sign in to comment.