Error 431 (Request Header Fields Too Large)

I am getting a very large encrypted string in the URL and when it enters my wix site, I decrypt the code and wix shows this error in the console: Failed to load resource: the server responded with a status of 431 (Request Header Fields Too Large ) in all browsers. My encryption and decryption code is:

export function Encriptar(dados){
var mensx=“”;
var l;
var i;
var j=0;
var ch;
//ch = “assbdFbdpdPdpfPdAAdpeoseslsQQEcDDldiVVkadiedkdkLLnm”;
ch = “AkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAktAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAktAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAktAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAktAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAktAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkt”;

for (i=0;i<dados.length; i++){
j=j+1;
console.log(j);
l=(Asc(dados.substr(i,1))+(Asc(ch.substr(j,1))));
console.log(Asc(dados.substr(i,1)));
console.log(Asc(ch.substr(j,1)));
console.log(Asc(dados.substr(i,1))+Asc(ch.substr(j,1)));
if (j===ch.length-1){
j=1;
}
if (l>255){
l-=256;
}
mensx+=(Chr(l));
//var caracteresEspeciais = new Array([6][2]);
//caracteresEspeciais[6][2];

//var caracteresEspeciais = new [6,2];
//caracteresEspeciais[0, 0] = “%”; caracteresEspeciais[0, 1] = “%25”;
//caracteresEspeciais[1, 0] = “+”; caracteresEspeciais[1, 1] = “%2B”;
//caracteresEspeciais[2, 0] = “/”; caracteresEspeciais[2, 1] = “%2F”;
//caracteresEspeciais[3, 0] = “?”; caracteresEspeciais[3, 1] = “%3F”;
//caracteresEspeciais[4, 0] = “#”; caracteresEspeciais[4, 1] = “%23”;
//caracteresEspeciais[5, 0] = “&”; caracteresEspeciais[5, 1] = “%26”;

            mensx = mensx.replace("%","%25"); 
            mensx = mensx.replace("+","%2B"); 
            mensx = mensx.replace("/","%2F"); 
            mensx = mensx.replace("?","%3F"); 
            mensx = mensx.replace("#","%23"); 
            mensx = mensx.replace("&","%26");    

//return retorno;
//console.log(“mensx=”+mensx+" i=“+i+” “+ dados.substr(i,1) +” "+(ch.substr(j,1)) );
}

console.log("substring="+mensx.substr(mensx.length-1, 1)); 

return mensx;
}

export function Descriptar(dados){
var mensx=“”;
var l;
var i;
var j=0;
var ch;
//ch = “assbdFbdpdPdpfPdAAdpeoseslsQQEcDDldiVVkadiedkdkLLnm”;
ch = “AkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAktAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAktAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAktAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAktAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAktAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkttomAkt”;
for (i=0; i<dados.length;i++){
j++;
l=(Asc(dados.substr(i,1))-(Asc(ch.substr(j,1))));
if (j===ch.length-1){
j=1;
}
if (l<0){
l+=256;
}
mensx+=(Chr(l));
}
return mensx;

}

function Asc(String){
return String.charCodeAt(0);
}

function Chr(AsciiNum){
return String.fromCharCode(AsciiNum);
}

I don’t believe that the encrypt/decrypt functions have anything to do with the error. The error appears to be exactly what it says: Error 431 (Request Header Fields Too Large) . You should check your request and make sure that the header is not too big.

I have no way of knowing the size of the header since this is dynamic, so it has to work for all header sizes.