@netlify/content-engine
Version:
24 lines • 1.41 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRequestHeadersForUrl = getRequestHeadersForUrl;
const url_1 = __importDefault(require("url"));
// in tests we don't want to log the warning
let loggedWarning = process.env.NODE_ENV === `test`;
function getRequestHeadersForUrl(passedUrl, store) {
const storeIsMissing = !store || !(`getState` in store);
if (storeIsMissing && !loggedWarning) {
loggedWarning = true;
console.warn(`Gatsby's redux store is required in the "addRemoteFilePolyfillInterface" and "polyfillImageServiceDevRoutes" API's for image CDN. No store was found when requesting url "${passedUrl}". This will fail your build in Gatsby V5. Upgrade your source plugins and Gatsby packages to the latest versions to resolve this. If you are a source plugin author visit https://gatsby.dev/source-plugins-image-cdn to learn how to make this warning go away.`);
}
if (storeIsMissing) {
return undefined;
}
const baseDomain = url_1.default.parse(passedUrl).hostname;
// @ts-ignore todo type store
const { requestHeaders } = store.getState();
return baseDomain ? requestHeaders?.get(baseDomain) : undefined;
}
//# sourceMappingURL=get-request-headers-for-url.js.map
;