The availability of link sharing online allows for the quick dispersion of ideas, news, and other stuff throughout the web. However, the spike in link sharing has resulted in malicious hyperlinks that spread malware, steal data, and enable hacking attempts. Many scams include consumers getting fake links that attempt to compromise their account details. To tackle this growing threat, tech companies increasingly use link preview services, which allow users to assess shared links before accessing them.
What is the reason for encouraging visitors to URL link preview before clicking on them?
There are two key reasons why users should consider link preview before clicking.
- First, it gives viewers a visual preview of the URL, which helps them decide whether or not to proceed.
- Second, it acts as a preventative step against risky data, notifying users and guiding them away from potential fraud and hacking attempts.
- Also, link scanners play an important role by cross-referencing links with databases of reported threats, successfully identifying and warning users of risky links, and protecting them from potential damage.
How to Create a Secure Url Link Preview with NodeJs
Set up your Project
mkdir link-preview-nodejs
cd link-preview-nodejs
Install the dependencies
npm i link-preview-js
Create a File in your Project Folder
The next step is to create a new file, such as UrllinkPreview.js, and write the logic.
const { getLinkPreview } = require("link-preview-js");
async function init() {
try {
const response = await getLinkPreview('https://github.com/', {
imagesPropertyType: "og", headers: {
"user-agent": "googlebot",
'Accept-Language': 'en-US'
},
timeout: 10000
});
console.log(response)
} catch (error) {
console.error(error);
}
}
init();
Run your Project
Once you have added the link preview js to generate link preview, you can try the implementation. In your terminal, run this command:
mkdir link-preview-nodejs
node index.js