mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-14 07:52:15 +00:00
fix(api): Allow x-client to be set in cors middleware (#8117)
* fix(api): Allow x-client to be set in cors middleware * chore: update cors middlware tests
This commit is contained in:
parent
578dee59bd
commit
8db6b7c6cb
2 changed files with 3 additions and 3 deletions
|
|
@ -20,7 +20,7 @@ describe('cors middleware', () => {
|
|||
expect(res.set).to.have.been.calledWith({
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Methods': 'OPTIONS,GET,POST,PUT,HEAD,DELETE',
|
||||
'Access-Control-Allow-Headers': 'Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key',
|
||||
'Access-Control-Allow-Headers': 'Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key,x-client',
|
||||
});
|
||||
expect(res.sendStatus).to.not.have.been.called;
|
||||
expect(next).to.have.been.called.once;
|
||||
|
|
@ -32,7 +32,7 @@ describe('cors middleware', () => {
|
|||
expect(res.set).to.have.been.calledWith({
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Methods': 'OPTIONS,GET,POST,PUT,HEAD,DELETE',
|
||||
'Access-Control-Allow-Headers': 'Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key',
|
||||
'Access-Control-Allow-Headers': 'Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key,x-client',
|
||||
});
|
||||
expect(res.sendStatus).to.have.been.calledWith(200);
|
||||
expect(next).to.not.have.been.called;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ module.exports = function corsMiddleware (req, res, next) {
|
|||
res.set({
|
||||
'Access-Control-Allow-Origin': req.header('origin') || '*',
|
||||
'Access-Control-Allow-Methods': 'OPTIONS,GET,POST,PUT,HEAD,DELETE',
|
||||
'Access-Control-Allow-Headers': 'Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key',
|
||||
'Access-Control-Allow-Headers': 'Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key,x-client',
|
||||
});
|
||||
if (req.method === 'OPTIONS') return res.sendStatus(200);
|
||||
return next();
|
||||
|
|
|
|||
Loading…
Reference in a new issue