Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ module.exports = {
async onBuild({ netlifyConfig, constants, inputs, utils }) {
console.log('[Cloudinary] Creating redirects...');

const { PUBLISH_DIR } = constants;

const isProduction = process.env.CONTEXT === 'production';
const host = isProduction ? process.env.NETLIFY_HOST : process.env.DEPLOY_PRIME_URL;

console.log(`[Cloudinary] Using host: ${host}`);

const { PUBLISH_DIR } = constants;

const {
deliveryType,
uploadPreset,
Expand Down Expand Up @@ -155,7 +155,10 @@ module.exports = {
async onPostBuild({ constants, inputs, utils }) {
console.log('[Cloudinary] Replacing on-page images with Cloudinary URLs...');

const host = process.env.DEPLOY_PRIME_URL || process.env.NETLIFY_HOST;
const isProduction = process.env.CONTEXT === 'production';
const host = isProduction ? process.env.NETLIFY_HOST : process.env.DEPLOY_PRIME_URL;

console.log(`[Cloudinary] Using host: ${host}`);

if ( !host ) {
console.warn(`[Cloudinary] ${ERROR_NETLIFY_HOST_UNKNOWN}`);
Expand All @@ -166,7 +169,6 @@ module.exports = {
const { PUBLISH_DIR } = constants;
const {
deliveryType,
loadingStrategy,
uploadPreset,
folder = process.env.SITE_NAME
} = inputs;
Expand Down