mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: follow redirects in API
This commit is contained in:
@@ -61,6 +61,11 @@ async function xhr(options) {
|
|||||||
|
|
||||||
const res = await fetch(url, options);
|
const res = await fetch(url, options);
|
||||||
const { headers } = res;
|
const { headers } = res;
|
||||||
|
|
||||||
|
if (headers.get('x-redirect')) {
|
||||||
|
return xhr({ url: headers.get('x-redirect'), ...options });
|
||||||
|
}
|
||||||
|
|
||||||
const contentType = headers.get('content-type');
|
const contentType = headers.get('content-type');
|
||||||
const isJSON = contentType && contentType.startsWith('application/json');
|
const isJSON = contentType && contentType.startsWith('application/json');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user