I am building a webapp using Node and my server needs to be forwarded the API call that a user wants to make. Basically in the frontend the user enters the API call they want to make. A request should then be sent to the server with the details of that call.
What is the best way to send that information?
This is a very simple example but let me know if you need more detail.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<script>
function redirect(){
//url you want to encrypt
url = "http://www.test.com";
//url encryption with BTOA function
base64Url = btoa(url)
// Lets Redirect to the new url with URL encrypted
window.location = "http://www.newAddress.com?url="+base64Url
}
</script>
<body>
<a href="#" onclick="redirect()">redirect</a>
</body>
</html>
This will let you send the url trough the query string, in the other side you just get the string and decode it, it is base64 if you are using javascript you can use the function atob() to decode what we encode with btoa or any other base64 decoder if you are in other languages.
For more details you can check this page https://developer.mozilla.org/en/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.