parseKitchenMediaUrl (resolve-local-media.ts)

kitchen-plugin-marketing · database, url-parsing, media-resolution, files

Fast-path resolver for Kitchen plugin media URLs. The plugin's `publishViaPostiz` step needs to upload media bytes to Postiz. The media URLs the plugin hands it look like: /api/plugins/marketing/media/<uuid>/file?team=<teamId>

/**
 * Fast-path resolver for Kitchen plugin media URLs.
 *
 * The plugin's `publishViaPostiz` step needs to upload media bytes to Postiz.
 * The media URLs the plugin hands it look like:
 *
 *     /api/plugins/marketing/media/<uuid>/file?team=<teamId>
 *
 * The obvious approach — `fetch(kitchenBaseUrl + url)` — fails under a common
 * "hairpin" networking scenario: when the Kitchen plugin is only listening on
 * a non-loopback IP (e.g. a Tailscale private address), a server process
 * cannot always connect back to its own external listening socket. Undici
 * reports this as a generic `"fetch failed"` error and the whole publish
 * falls over.
 *
 * Since the plugin has direct access to its own media store (same process,
 * same filesystem), we can skip HTTP entirely and read the file from

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key