Skip to content

Commit d15a3ce

Browse files
committed
Adds exposed headers to avoid issue in JS SDK (#4934)
* Adds exposed headers to avoid issue in JS SDK * Adds test for headers
1 parent 0c2f1d5 commit d15a3ce

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

spec/Middlewares.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,16 @@ describe('middlewares', () => {
290290
middlewares.handleParseHeaders(fakeReq, fakeRes);
291291
expect(fakeRes.status).toHaveBeenCalledWith(403);
292292
});
293+
294+
it('should properly expose the headers', () => {
295+
const headers = {};
296+
const res = {
297+
header: (key, value) => {
298+
headers[key] = value
299+
}
300+
};
301+
middlewares.allowCrossDomain({}, res, () => {});
302+
expect(Object.keys(headers).length).toBe(4);
303+
expect(headers['Access-Control-Expose-Headers']).toBe('X-Parse-Job-Status-Id, X-Parse-Push-Status-Id');
304+
});
293305
});

src/middlewares.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export function allowCrossDomain(req, res, next) {
247247
res.header('Access-Control-Allow-Origin', '*');
248248
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
249249
res.header('Access-Control-Allow-Headers', 'X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, Content-Type');
250-
250+
res.header('Access-Control-Expose-Headers', 'X-Parse-Job-Status-Id, X-Parse-Push-Status-Id');
251251
// intercept OPTIONS method
252252
if ('OPTIONS' == req.method) {
253253
res.sendStatus(200);

0 commit comments

Comments
 (0)