🛠 Minor improvements to the reverse proxy
This commit is contained in:
@@ -36,11 +36,25 @@ export default class ApplicationsApiService extends TdriveService<undefined> {
|
||||
},
|
||||
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 }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user