Skip to content

[Bug Fix] Forward response headers so front end can correctly handle content-encoding #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ app.use('/api/v1/brokerPath/', (req, res, next) => {
res.status(resp.status).send(JSON.stringify(resp.data))
}).catch((error) => {
console.error(error);
res.status(error.response.status).send(error.response.data)
if(error.response){
res.status(error.response.status).send(error.response.data)
}else{
res.status(500).send(error.response?.data)
}
})
})

Expand Down Expand Up @@ -148,6 +152,11 @@ const onProxyRes = (proxyRes, req, res) => {
cfg.L.warn('proxy request failed with status ' + proxyRes.statusCode + ', url: \'' + proxyRes.req.host + proxyRes.req.path + '\'')
}

// set the response headers so that the frontend can decode the content
Object.keys(proxyRes.headers).forEach((key) => {
res.setHeader(key, proxyRes.headers[key]);
});

if (proxyRes?.headers?.location) {
const headers = req.headers;
const body = req.body;
Expand Down