Code RoomRedirect to internal network
MediumPrep Room Coding #1662

Redirect to internal network

Code reviewCode quality & reviewMid–Senior~25 min

Review this Node.js (Express) image-proxy used to thumbnail remote images.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 25 min
Mark a line and say what kind of problem it is.0 findings
1app.get('/thumb', async (req, res) => {
2 const src = req.query.src;
3 // only allow our CDN to avoid abuse
4 if (!src.startsWith('https://cdn.example.com')) {
5 return res.status(400).send('bad source');
6 }
7 const upstream = await fetch(src);
8 const buf = Buffer.from(await upstream.arrayBuffer());
9 const png = await sharp(buf).resize(200).png().toBuffer();
10 res.type('png').send(png);
11});
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.