I'm sending data from Client to the Backend in 2 forms: both encrypted and non encrypted.
I'm using this Express code:
const express = require('express');
const app = express();
// adding Middlewares ....
app.use(express.urlencoded({ extended: true, limit: '100mb', parameterLimit: 100000000 }));
app.use(express.json({ limit: '100mb'}));
When I POST a non encrypted body , something as:
method: 'POST',
uri: ** BACKEND-ENDPOINT ** ,
headers: {
'Content-type': 'application/json',
'yourAPIToken': // big token
},
json: true,
body: 'Some binary data goes here'
The request reaches the Backend and the body is accepted as sent.
However when using Encrypted data , doing something as follows:
const aesjs = require('aes-js');
let encryptedData;
// manipulating data with "aesjs" into "encryptedData"
const dataToSend = Buffer.from(encryptedData, 'binary');
And POSTing this using:
method: 'POST',
uri: ** BACKEND-ENDPOINT ** ,
headers: {
'Content-type': 'application/json',
'yourAPIToken': // big token
},
json: true,
body: dataToSend
This POST request is accepted in the Backend with empty body , as follows: {}.
Why when I send the data encrypted the Body-Parser of Middleware doesn't work , and how can we fix the Body from being empty ?