Search code examples
javanode.jsspring-bootnode-rest-client

Character are omitting while sending request to server(Spring Boot) from client (NodeJS)


I have Spring Boot and NodeJS application. Where Spring boot has set of API which are called from NodeJS application.

Because of business requirement, I am encrypting some value on Spring Boot application and sending it to NodeJS application.

In application flow, I had to send encrypted token from NodeJS application to Spring Boot application where I will be doing decryption for further processing.

Now, when I send encrypted token to Spring Boot application, I see some the character are omitting. For example, + is replaced with (new line or empty string) and due to this I am not able to perform decryption.

To be more explicit, ..1nfppOsSaMxTBIPq1x16K9L68Mo+JaaDNrgiNvkdWVOasyRCeh7rsEJEyd/syxiO.. replaced with ..1nfppOsSaMxTBIPq1x16K9L68Mo JaaDNrgiNvkdWVOasyRCeh7rsEJEyd/syxiO... I think, its something to do with encoding or escaping of character.

I tried to set content-type in request header but no luck. Can someone help me, how to fix this issue?

On NodeJS side, I am using node-rest-client to send POST request. AES algorithm is used for encryption and decryption.


Solution

  • It seems, your token was sent as url param, and the server tries to decode it. Just try to encode token on client side using encodeURIComponent function.