{"id":13454015,"url":"https://github.com/ymtszw/link-preview","last_synced_at":"2026-03-05T09:33:13.260Z","repository":{"id":70224236,"uuid":"576324552","full_name":"ymtszw/link-preview","owner":"ymtszw","description":"\"link-preview\" service on Cloudflare Workers","archived":false,"fork":false,"pushed_at":"2026-02-16T03:56:16.000Z","size":348,"stargazers_count":25,"open_issues_count":0,"forks_count":28,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-16T11:17:01.700Z","etag":null,"topics":["cloudflare-workers","link-preview"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ymtszw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-12-09T15:00:16.000Z","updated_at":"2026-02-16T03:56:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"eba8b225-a6bb-4d65-a8ba-7e44f0a35a38","html_url":"https://github.com/ymtszw/link-preview","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ymtszw/link-preview","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymtszw%2Flink-preview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymtszw%2Flink-preview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymtszw%2Flink-preview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymtszw%2Flink-preview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ymtszw","download_url":"https://codeload.github.com/ymtszw/link-preview/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymtszw%2Flink-preview/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30117718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T08:19:04.902Z","status":"ssl_error","status_checked_at":"2026-03-05T08:17:37.148Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-workers","link-preview"],"created_at":"2024-07-31T08:00:50.307Z","updated_at":"2026-03-05T09:33:13.208Z","avatar_url":"https://github.com/ymtszw.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# link-preview\n\n## What is this?\n\nThis is a **light-weight, no-auth \"link-preview\" service** powered by [Cloudflare Workers](https://www.cloudflare.com/products/workers/)\nand [node-html-parser](https://github.com/taoqf/node-html-parser)\n\n- For small- or single-purpose services, Cloudflare Workers are very good environment to work with.\n  - It enables small-start from free tier, with generous feature offerings\n  - It allows us exactly what we want in this context: writing in TypeScript, serving public HTTP APIs to the world\n  - It has well-made development experience: rich documents, wrangler CLI, easy deploy from GitHub Actions, consice user-land directory structure, etc.\n- `node-html-parser` fits here as well.\n  - Reasonably small set of dependencies\n  - Sufficiently fast (subjectively though, not benchmarked)\n  - Well-known `querySelector` API\n\n## Why a Service, not a Library?\n\nThere are libraries like [link-preview-js](https://github.com/ospfranco/link-preview-js) and they serve the purpose as long as you know what you are doing.\n\nHowever, there are [gotchas](https://github.com/ospfranco/link-preview-js#gotchas):\n\n- When you attempt to fetch a website of another origin from JavaScript run on a web browser, the browser ask the targeted website for **cross-origin request allowances (CORS; Cross-Origin Resource Sharing)** due to the same-origin policies\n- However, not all websites allow CORS. Or rather, most websites just don't (default behavior of ordinary web servers)\n- In this scenario, non-browser agent must fetch the website, and pass the result to the initiating script\n- **This service exactly does that**\n  - Fetch websites of another domain on behalf of browser-run script\n  - Extract essential info for preview purpose from the website (`title` and `url`, optional `description` and `image`)\n  - Give it back to the requester in JSON format\n\nThis service itself **allows** CORS, so you can just pitch requests from whatever environment and they should work.\n\nAlso it comes in rescue when your preferred language does not have well-maintained link-preview libraries.\nYou just need some HTTP client capability and JSON handling.\n\n## How to deploy\n\n1. Prepare your Cloudflare Account\n2. Click: [![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/ymtszw/link-preview)\n   - It should fork this repository and set up your Cloudflare Account, then deploys the service\n\n## Develop locally\n\n```sh\nnpm install\nnpm start\n```\n\nThen, from another terminal:\n\n```sh\n$ curl 'http://localhost:8787?q=https://cloudflare.com' | jq .\n{\n  \"title\": \"Cloudflare - The Web Performance \u0026 Security Company\",\n  \"description\": \"Here at Cloudflare, we make the Internet work the way it should. Offering CDN, DNS, DDoS protection and security, find out how we can help your site.\",\n  \"url\": \"https://www.cloudflare.com/\",\n  \"image\": \"https://www.cloudflare.com/static/b30a57477bde900ba55c0b5f98c4e524/Cloudflare_default_OG_.png\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymtszw%2Flink-preview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fymtszw%2Flink-preview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymtszw%2Flink-preview/lists"}