diff --git a/modules/mining-checker/assets/js/app.js b/modules/mining-checker/assets/js/app.js index ec1e7e7..7ab9ada 100644 --- a/modules/mining-checker/assets/js/app.js +++ b/modules/mining-checker/assets/js/app.js @@ -205,7 +205,12 @@ let response; try { - response = await fetch(requestUrl, { ...requestOptions, signal: controller.signal }); + response = await fetch(requestUrl, { + ...requestOptions, + credentials: 'same-origin', + redirect: 'manual', + signal: controller.signal, + }); } catch (error) { window.clearTimeout(timeoutId); if (error && error.name === 'AbortError') { @@ -224,12 +229,26 @@ type: 'request:error', method: requestOptions.method || 'GET', url: requestUrl, + page_url: window.location.href, + online: window.navigator ? window.navigator.onLine : null, message: error && error.message ? error.message : 'Fetch fehlgeschlagen', }); throw error; } window.clearTimeout(timeoutId); + if (response.type === 'opaqueredirect' || (response.status >= 300 && response.status < 400)) { + const location = response.headers ? response.headers.get('Location') : ''; + emitDebug({ + type: 'request:redirect', + method: requestOptions.method || 'GET', + url: requestUrl, + status: response.status, + location: location || null, + }); + throw new Error(`API request wurde weitergeleitet${location ? ` nach ${location}` : ''}. Bitte Login/Session und Proxy-Rewrite pruefen.`); + } + const payload = await response.json().catch(() => ({})); emitDebug({ type: 'request:response',