Skip to content

Commit

Permalink
Correctly handle body for request
Browse files Browse the repository at this point in the history
  • Loading branch information
inventionpro committed Dec 21, 2024
1 parent 15ff71a commit 5a36927
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ fastify.post('/request', async(req, res) => {
let url = req.query['url'];
url = (url.includes('://') ? '' : 'https://') + url;

let body = JSON.parse(req.body);
let body = req.body;
if (typeof body == 'string') {
body = JSON.parse(req.body);
}
if (body.headers['content-type']?.startsWith('image/')) {
body.body = Buffer.from(body.body.replace(/^data:image\/\w+;base64,/, ''), 'base64');
}
Expand Down

0 comments on commit 5a36927

Please sign in to comment.