diff --git a/tdrive/backend/node/src/services/applications-api/index.ts b/tdrive/backend/node/src/services/applications-api/index.ts index 07caa521..6606ae83 100644 --- a/tdrive/backend/node/src/services/applications-api/index.ts +++ b/tdrive/backend/node/src/services/applications-api/index.ts @@ -36,11 +36,25 @@ export default class ApplicationsApiService extends TdriveService { }, data: req.body as any, responseType: "stream", + maxRedirects: 0, + validateStatus: null, }); + + // Redirects + if (response.status === 301 || response.status === 302) { + rep.redirect(response.headers.location); + return; + } + + // Headers + for (const key in response.headers) { + rep.header(key, response.headers[key]); + } + rep.statusCode = response.status; rep.send(response.data); } catch (err) { - console.error(err); + console.error(`${err}`); rep.raw.statusCode = 500; rep.raw.end(JSON.stringify({ error: err.message })); }