asd
This commit is contained in:
@@ -205,7 +205,12 @@
|
|||||||
|
|
||||||
let response;
|
let response;
|
||||||
try {
|
try {
|
||||||
response = await fetch(requestUrl, { ...requestOptions, signal: controller.signal });
|
response = await fetch(requestUrl, {
|
||||||
|
...requestOptions,
|
||||||
|
credentials: 'same-origin',
|
||||||
|
redirect: 'manual',
|
||||||
|
signal: controller.signal,
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window.clearTimeout(timeoutId);
|
window.clearTimeout(timeoutId);
|
||||||
if (error && error.name === 'AbortError') {
|
if (error && error.name === 'AbortError') {
|
||||||
@@ -224,12 +229,26 @@
|
|||||||
type: 'request:error',
|
type: 'request:error',
|
||||||
method: requestOptions.method || 'GET',
|
method: requestOptions.method || 'GET',
|
||||||
url: requestUrl,
|
url: requestUrl,
|
||||||
|
page_url: window.location.href,
|
||||||
|
online: window.navigator ? window.navigator.onLine : null,
|
||||||
message: error && error.message ? error.message : 'Fetch fehlgeschlagen',
|
message: error && error.message ? error.message : 'Fetch fehlgeschlagen',
|
||||||
});
|
});
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.clearTimeout(timeoutId);
|
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(() => ({}));
|
const payload = await response.json().catch(() => ({}));
|
||||||
emitDebug({
|
emitDebug({
|
||||||
type: 'request:response',
|
type: 'request:response',
|
||||||
|
|||||||
Reference in New Issue
Block a user