mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 00:39:49 +00:00
feat(license): use strapi.fetch method instead of fetch
This commit is contained in:
parent
2e95fd6eaf
commit
25c15f9ebf
@ -105,7 +105,9 @@ const onlineUpdate = async ({ strapi }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const license = shouldContactRegistry
|
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;
|
: storedInfo.license;
|
||||||
|
|
||||||
if (license) {
|
if (license) {
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { join } = require('path');
|
const { join } = require('path');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const fetch = require('node-fetch');
|
|
||||||
|
|
||||||
const machineId = require('../lib/utils/machine-id');
|
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);
|
throw new LicenseCheckError('Could not proceed to the online validation of your license.', true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchLicense = async (key, projectId) => {
|
const fetchLicense = async ({ strapi }, key, projectId) => {
|
||||||
const response = await fetch(`https://license.strapi.io/api/licenses/validate`, {
|
const response = await strapi
|
||||||
method: 'POST',
|
.fetch(`https://license.strapi.io/api/licenses/validate`, {
|
||||||
headers: { 'Content-Type': 'application/json' },
|
method: 'POST',
|
||||||
body: JSON.stringify({ key, projectId, deviceId: machineId() }),
|
headers: { 'Content-Type': 'application/json' },
|
||||||
}).catch(throwError);
|
body: JSON.stringify({ key, projectId, deviceId: machineId() }),
|
||||||
|
})
|
||||||
|
.catch(throwError);
|
||||||
|
|
||||||
const contentType = response.headers.get('Content-Type');
|
const contentType = response.headers.get('Content-Type');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user