npm package diff

Package: @forge/api

Versions: 3.8.1-experimental-10722bc - 3.9.2-next.1

File: package/out/api/fetch.js

Index: package/out/api/fetch.js
===================================================================
--- package/out/api/fetch.js
+++ package/out/api/fetch.js
@@ -21,11 +21,10 @@
 function fetchProduct(args) {
     return async (path, init) => {
         const url = productURL(args.remote, path);
         init = (0, exports.addMagicAgent)(init);
-        if (!hasAuthorizationHeader(init.headers)) {
-            init.headers = { ...init.headers, authorization: `Forge ${args.provider}` };
-        }
+        const defaultHeaders = getDefaultHeaders(init.headers, args);
+        init.headers = { ...init.headers, ...defaultHeaders };
         const response = await (0, node_fetch_1.default)(url, init);
         (0, exports.handleProxyResponseErrors)(response);
         return response;
     };
@@ -84,12 +83,18 @@
         throw new errors_1.ProxyRequestError(response.status, errorReason);
     }
 };
 exports.handleProxyResponseErrors = handleProxyResponseErrors;
-const hasAuthorizationHeader = (headersInit) => {
-    if (!headersInit)
-        return false;
-    return new node_fetch_1.Headers(headersInit).has('authorization');
+const getDefaultHeaders = (headersInit, args) => {
+    let defaultHeaders = {};
+    const headers = new node_fetch_1.Headers(headersInit);
+    if (!headers.has('Content-Type')) {
+        defaultHeaders = { 'Content-Type': 'application/json' };
+    }
+    if (!headers.has('authorization')) {
+        defaultHeaders = { ...defaultHeaders, authorization: `Forge ${args.provider}` };
+    }
+    return defaultHeaders;
 };
 function productURL(remote, path) {
     if (!path.startsWith('/')) {
         path = '/' + path;