🔒 Updates CORS proxy to use res.status

This commit is contained in:
Alicia Sykes 2022-01-21 13:00:26 +00:00
parent 58a085a550
commit 6cd9eac49b
1 changed files with 3 additions and 3 deletions

View File

@ -23,7 +23,7 @@ module.exports = (req, res) => {
// Get desired URL, from Target-URL header // Get desired URL, from Target-URL header
const targetURL = req.header('Target-URL'); const targetURL = req.header('Target-URL');
if (!targetURL) { if (!targetURL) {
res.send(500, { error: 'There is no Target-Endpoint header in the request' }); res.status(500).send({ error: 'There is no Target-Endpoint header in the request' });
return; return;
} }
// Apply any custom headers, if needed // Apply any custom headers, if needed
@ -40,8 +40,8 @@ module.exports = (req, res) => {
// Make the request, and respond with result // Make the request, and respond with result
axios.request(requestConfig) axios.request(requestConfig)
.then((response) => { .then((response) => {
res.send(200, response.data); res.status(200).send(response.data);
}).catch((error) => { }).catch((error) => {
res.send(500, { error }); res.status(500).send({ error });
}); });
}; };