Skip to content

Commit c450c2f

Browse files
committed
fix(): remove malformed auth headers
1 parent 6d6ae95 commit c450c2f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

server/routes/post.route.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import express from 'express';
22
import expressJwt from 'express-jwt';
33
import validate from 'express-validation';
4+
import omit from 'lodash/omit';
45
import paramValidation from '../../config/param-validation';
56
import postCtrl from '../controllers/post.controller';
67
import voteCtrl from '../controllers/vote.controller';
@@ -14,8 +15,17 @@ import loadFullUser from '../middleware/loadFullUser.middleware';
1415

1516
const router = express.Router(); // eslint-disable-line new-cap
1617

18+
// @TODO: Remove this after it's fixed in iOS
19+
const jwtCleanUp = (req, res, next) => {
20+
if (req.headers.authorization && !req.headers.authorization.split(' ')[1]) {
21+
req.headers = omit(req.headers, 'authorization');
22+
}
23+
next();
24+
};
25+
1726
router.route('/')
1827
.get(
28+
jwtCleanUp,
1929
expressJwt({
2030
secret: config.jwtSecret,
2131
credentialsRequired: false,

0 commit comments

Comments
 (0)