Skip to content

Node.js based forum software built for the modern web

feat: follow redirects in API

Oplikoe0138cbede23
diff --git a/public/src/modules/api.js b/public/src/modules/api.js
index f510586549..95d5d35a1e 100644
--- a/public/src/modules/api.js
+++ b/public/src/modules/api.js
@@ -61,6 +61,11 @@ async function xhr(options) {
const res = await fetch(url, options);
const { headers } = res;
+
+ if (headers.get('x-redirect')) {
+ return xhr({ url: headers.get('x-redirect'), ...options });
+ }
+
const contentType = headers.get('content-type');
const isJSON = contentType && contentType.startsWith('application/json');