Skip to content

Commit

Permalink
fix: add missing Content-Type header
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Mar 26, 2022
1 parent 0a94d53 commit 6903318
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/sync-manager.ts
Expand Up @@ -441,11 +441,16 @@ class PushLoop extends Loop {

let response;
try {
response = await fetch(url, {
const options = {
method,
body: value ? JSON.stringify(value) : undefined,
headers: {},
...this.opts.fetchOptions,
});
}
if (value) {
options.body = JSON.stringify(value);
options.headers['Content-Type'] = 'application/json';
}
response = await fetch(url, options);
} catch (e) {
return retryAfter(DEFAULT_RETRY_DELAY);
}
Expand Down
1 change: 1 addition & 0 deletions test/sync-server.js
Expand Up @@ -44,6 +44,7 @@ const server = createServer(async (req, res) => {
switch (req.method) {
case 'OPTIONS':
res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
res.writeHead(204).end();
break;
case 'GET':
Expand Down

0 comments on commit 6903318

Please sign in to comment.