Link previews for Editor.js
The official @editorjs/link plugin needs a backend that fetches the page and returns {"success":1,"meta":{"title","description","image":{"url"}}}. Browsers can't fetch other sites directly because of CORS, so you'd normally write that server yourself. /v1/linktool is that backend.
Setup
import LinkTool from "@editorjs/link";
new EditorJS({
tools: {
linkTool: {
class: LinkTool,
config: { endpoint: "https://YOUR-UNFURLR-HOST/v1/linktool?key=pk_YOUR_PUBLISHABLE_KEY" }
}
}
});
The plugin sends GET endpoint?url=…; we always answer HTTP 200 with success: 1 or success: 0 plus an error, so the plugin never crashes.
Limits, honestly
- A key in browser code is public. Use a publishable
pk_key (set allowed origins, thenPOST /v1/keys/publishable): it works only from your origins, only for link previews, and has its own small quota (100/month, 5/min) separate from your account's 500. If it leaks, only that small quota can be used up. Secretmk_keys are refused in the URL. - For more, proxy from your backend and send your secret key as
X-API-Key. Never put the secret key in the plugin'sheadersconfig: that's visible in the browser too. - No JavaScript rendering; X, Reddit and Meta pages aren't supported.