@rmdes/indiekit-endpoint-webmentions-proxy
v1.0.1
Published
Webmentions proxy endpoint for Indiekit. Proxies webmention.io API requests with server-side authentication.
Maintainers
Readme
@rmdes/indiekit-endpoint-webmentions-proxy
Webmentions proxy endpoint for Indiekit. Proxies webmention.io API requests with server-side authentication, enabling real-time webmention fetching from frontend applications without exposing API tokens.
Why This Plugin Exists
The official @indiekit/endpoint-webmention-io plugin provides an admin dashboard view at /webmentions, but:
- No public API - Only provides protected routes (requires authentication)
- No database storage - Fetches directly from webmention.io on each request, doesn't cache in MongoDB
- Renders HTML - Returns server-rendered views, not JSON for frontend consumption
For a static site (like Eleventy) that needs real-time webmentions on the frontend via JavaScript fetch, the options were:
| Approach | Drawback | |----------|----------| | Expose token to frontend | Security risk - token visible in browser | | Build-time data fetching | Not real-time, requires rebuild for updates | | Fork official plugin | Maintenance burden of tracking upstream | | Dedicated proxy plugin | Small additional dependency (this plugin) |
This plugin takes the dedicated proxy approach: a small, single-purpose endpoint (~70 lines) that keeps the token server-side while providing a public JSON API for frontends.
Installation
npm install @rmdes/indiekit-endpoint-webmentions-proxyConfiguration
// indiekit.config.js
export default {
plugins: [
"@rmdes/indiekit-endpoint-webmentions-proxy",
],
"@rmdes/indiekit-endpoint-webmentions-proxy": {
mountPath: "/webmentions-api", // API mount path (default)
token: process.env.WEBMENTION_IO_TOKEN, // Your webmention.io token
domain: "example.com", // Domain to fetch webmentions for
cacheTtl: 60, // Cache TTL in seconds (default: 60)
},
};API Endpoints
GET /webmentions-api/api/mentions
Fetch webmentions from webmention.io.
Query Parameters:
page- Page number (default: 0)per-page- Items per page (default: 50)
Response: JF2 format webmentions from webmention.io
License
MIT
