Webmentions proxy endpoint for Indiekit - proxies webmention.io API with server-side authentication
  • JavaScript 100%
Find a file
Ricardo 79d7ef6064 docs: add CLAUDE.md technical reference
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 18:23:20 +01:00
lib fix: improve API parameter forwarding and error handling 2026-01-28 15:08:04 +01:00
CLAUDE.md docs: add CLAUDE.md technical reference 2026-02-13 18:23:20 +01:00
index.js docs: explain why this plugin exists 2026-01-27 08:26:25 +01:00
package.json chore: bump version to 1.0.3 2026-02-06 16:41:18 +01:00
README.md fix: improve API parameter forwarding and error handling 2026-01-28 15:08:04 +01:00

@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:

  1. No public API - Only provides protected routes (requires authentication)
  2. No database storage - Fetches directly from webmention.io on each request, doesn't cache in MongoDB
  3. 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-proxy

Configuration

// 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)
  • target - Filter by specific URL (optional)
  • wm-property - Filter by webmention type: in-reply-to, like-of, repost-of, mention-of (optional)

Response: JF2 format webmentions from webmention.io

Example:

// Fetch all webmentions for page 0
fetch('/webmentions-api/api/mentions?page=0&per-page=50')

// Fetch only likes for a specific post
fetch('/webmentions-api/api/mentions?target=https://example.com/post&wm-property=like-of')

License

MIT