diff --git a/packages/core/strapi/ee/index.js b/packages/core/strapi/ee/index.js index f8341facc9..e7b80f1ec7 100644 --- a/packages/core/strapi/ee/index.js +++ b/packages/core/strapi/ee/index.js @@ -105,7 +105,9 @@ const onlineUpdate = async ({ strapi }) => { }; const license = shouldContactRegistry - ? await fetchLicense(ee.licenseInfo.licenseKey, strapi.config.get('uuid')).catch(fallback) + ? await fetchLicense({ strapi }, ee.licenseInfo.licenseKey, strapi.config.get('uuid')).catch( + fallback + ) : storedInfo.license; if (license) { diff --git a/packages/core/strapi/ee/license.js b/packages/core/strapi/ee/license.js index 91b148355c..c09ca8bf83 100644 --- a/packages/core/strapi/ee/license.js +++ b/packages/core/strapi/ee/license.js @@ -3,7 +3,6 @@ const fs = require('fs'); const { join } = require('path'); const crypto = require('crypto'); -const fetch = require('node-fetch'); const machineId = require('../lib/utils/machine-id'); @@ -69,12 +68,14 @@ const throwError = () => { throw new LicenseCheckError('Could not proceed to the online validation of your license.', true); }; -const fetchLicense = async (key, projectId) => { - const response = await fetch(`https://license.strapi.io/api/licenses/validate`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ key, projectId, deviceId: machineId() }), - }).catch(throwError); +const fetchLicense = async ({ strapi }, key, projectId) => { + const response = await strapi + .fetch(`https://license.strapi.io/api/licenses/validate`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ key, projectId, deviceId: machineId() }), + }) + .catch(throwError); const contentType = response.headers.get('Content-Type');