Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,18 @@ async function simulatePDPPreview() {
const corsProxy = 'https://fcors.org/?url=';
const corsKey = '&key=Mg23N96GgR8O3NjU';
const fullUrl = `https://main--vitamix--aemsites.aem.network${url}`;
return fetch(`${corsProxy}${encodeURIComponent(fullUrl)}${corsKey}`);
const { origin } = window.location;
const staging = (
origin.endsWith('.aem.page')
|| origin === 'http://localhost:3000'
|| window.location.search.includes('stage=true')
) && !window.location.search.includes('stage=false');

return fetch(`${corsProxy}${encodeURIComponent(fullUrl)}${corsKey}`, {
headers: {
...(staging ? { 'x-env': 'stage' } : {}),
},
});
};
const { pathname } = new URL(window.location.href);
const resp = await corsProxyFetch(pathname);
Expand Down
Loading