mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
fix(cors): allow authorization header
This commit is contained in:
@@ -21,7 +21,7 @@ describe('cors middleware', () => {
|
|||||||
expect(res.set).to.have.been.calledWith({
|
expect(res.set).to.have.been.calledWith({
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
'Access-Control-Allow-Methods': 'OPTIONS,GET,POST,PUT,HEAD,DELETE',
|
'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,x-client',
|
'Access-Control-Allow-Headers': 'Authorization,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(res.sendStatus).to.not.have.been.called;
|
||||||
expect(next).to.have.been.calledOnce;
|
expect(next).to.have.been.calledOnce;
|
||||||
@@ -33,7 +33,7 @@ describe('cors middleware', () => {
|
|||||||
expect(res.set).to.have.been.calledWith({
|
expect(res.set).to.have.been.calledWith({
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
'Access-Control-Allow-Methods': 'OPTIONS,GET,POST,PUT,HEAD,DELETE',
|
'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,x-client',
|
'Access-Control-Allow-Headers': 'Authorization,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(res.sendStatus).to.have.been.calledWith(200);
|
||||||
expect(next).to.not.have.been.called;
|
expect(next).to.not.have.been.called;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ export default function corsMiddleware (req, res, next) {
|
|||||||
res.set({
|
res.set({
|
||||||
'Access-Control-Allow-Origin': req.header('origin') || '*',
|
'Access-Control-Allow-Origin': req.header('origin') || '*',
|
||||||
'Access-Control-Allow-Methods': 'OPTIONS,GET,POST,PUT,HEAD,DELETE',
|
'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,x-client',
|
'Access-Control-Allow-Headers': 'Authorization,Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key,x-client',
|
||||||
});
|
});
|
||||||
if (req.method === 'OPTIONS') return res.sendStatus(200);
|
if (req.method === 'OPTIONS') return res.sendStatus(200);
|
||||||
return next();
|
return next();
|
||||||
|
|||||||
Reference in New Issue
Block a user