diff --git a/lib/manager-webpack4/src/manager-config.ts b/lib/manager-webpack4/src/manager-config.ts index 53655c3caf4b..a64a18ed3943 100644 --- a/lib/manager-webpack4/src/manager-config.ts +++ b/lib/manager-webpack4/src/manager-config.ts @@ -42,8 +42,26 @@ export const getAutoRefs = async ( }; const checkRef = (url: string) => - fetch(`${url}/iframe.html`).then( - ({ ok }) => ok, + fetch(`${url}/iframe.html`, { + headers: { + Accept: 'application/json', + }, + }).then( + async ({ ok }) => { + if (ok) { + // so the status is ok, but if we'd ask for JSON we might get a response saying we need to authenticate. + const data = await fetch(`${url}/iframe.html`, { + headers: { + Accept: 'application/json', + }, + }); + // we might receive non-JSON as a response, because the service ignored our request for JSON response type. + if (data.ok && (await data.json().catch((e) => ({}))).loginUrl) { + return false; + } + } + return ok; + }, () => false ); diff --git a/lib/manager-webpack5/src/manager-config.ts b/lib/manager-webpack5/src/manager-config.ts index 53655c3caf4b..a64a18ed3943 100644 --- a/lib/manager-webpack5/src/manager-config.ts +++ b/lib/manager-webpack5/src/manager-config.ts @@ -42,8 +42,26 @@ export const getAutoRefs = async ( }; const checkRef = (url: string) => - fetch(`${url}/iframe.html`).then( - ({ ok }) => ok, + fetch(`${url}/iframe.html`, { + headers: { + Accept: 'application/json', + }, + }).then( + async ({ ok }) => { + if (ok) { + // so the status is ok, but if we'd ask for JSON we might get a response saying we need to authenticate. + const data = await fetch(`${url}/iframe.html`, { + headers: { + Accept: 'application/json', + }, + }); + // we might receive non-JSON as a response, because the service ignored our request for JSON response type. + if (data.ok && (await data.json().catch((e) => ({}))).loginUrl) { + return false; + } + } + return ok; + }, () => false );