Fix: properly handle wg-easy errors (#3849)

Also reverts #3768
pull/3846/merge
shamoon 3 months ago committed by GitHub
parent 0dc2f2e18a
commit 9ede44b12d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -15,7 +15,7 @@ export default function Component({ service }) {
return <Container service={service} error={infoError} />; return <Container service={service} error={infoError} />;
} }
if (!infoData || infoData.errorCode) { if (!infoData) {
return ( return (
<Container service={service}> <Container service={service}>
<Block label="wgeasy.connected" /> <Block label="wgeasy.connected" />

@ -69,7 +69,15 @@ export default async function wgeasyProxyHandler(req, res) {
}, },
); );
return res.json(JSON.parse(data)); const parsedData = JSON.parse(data);
if (parsedData.statusCode > 400) {
return res
.status(parsedData.statusCode)
.json({ error: { message: "Error communicating with Wg-Easy", data: parsedData } });
}
return res.json(parsedData);
} }
} }

Loading…
Cancel
Save