manutepowa

payload files proxy

by manutepowa
Databases & data
v3
^3.92.0
MIT

Overview

Summary generated from the README

Adds a file handler to a Payload upload collection that downloads a requested file from a configured origin site when it is missing locally. Files are saved into the local upload directory and then served by Payload as usual. It is meant for development only, requires local storage, and needs Payload 3.92 or newer.

Features

  • Downloads only the requested file when it is missing locally, including individual image variants
  • Appends a file handler without replacing existing handlers
  • Respects Payload read access before fetching
  • Limits downloads to 50 MiB and 15 seconds, rejects redirects and returns 502 on failure
  • Shares concurrent downloads of the same file within a process
  • Can be disabled through a config flag so it becomes a no-op

Use cases

  • Avoid syncing a large uploads folder when running a copy of a production site locally
  • Show production media in pages and the admin UI on a development server

From the author

Plugin to getting production files on a development server on demand.

Installation

npm i payload-files-proxy

1

Stars

0

Forks

1

Open Issues

1 months ago

Last Updated

31

Weekly Downloads

v2.0.1

npm Version

23.7 KB

Unpacked Size

0

Dependencies

GitHub stars

10 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20261
Dec 4, 20261
Dec 3, 20261
Dec 2, 20261
Dec 1, 20261
Nov 30, 20261
Nov 29, 20261
Nov 28, 20261
Nov 27, 20261
Nov 26, 20261
Nov 25, 20261
Nov 24, 20261
Nov 23, 20261
Nov 22, 20261
Nov 21, 20261
Nov 20, 20261
Nov 19, 20261
Nov 18, 20261
Nov 17, 20261
Nov 16, 20261
Nov 15, 20261
Nov 14, 20261
Nov 13, 20261
Nov 12, 20261
Nov 11, 20261
Nov 10, 20261
Nov 9, 20261
Nov 8, 20261
Nov 7, 20261
Nov 6, 20261
Nov 5, 20261
Nov 4, 20261
Nov 3, 20261
Nov 2, 20261
Nov 1, 20261
Oct 31, 20261
Oct 30, 20261
Oct 29, 20261
Oct 28, 20261
Oct 27, 20261
Oct 26, 20261
Oct 25, 20261
Oct 24, 20261
Oct 23, 20261
Oct 22, 20261
Oct 21, 20261
Oct 20, 20261
Oct 19, 20261
Oct 18, 20261
Oct 17, 20261
Oct 16, 20261
Oct 15, 20261
Oct 14, 20261
Oct 13, 20261
Oct 12, 20261
Oct 11, 20261
Oct 10, 20261
Oct 9, 20261
Oct 8, 20261
Oct 7, 20261
Oct 6, 20261
Oct 5, 20261
Oct 4, 20261
Oct 3, 20261
Oct 2, 20261
Oct 1, 20261
Sep 30, 20261
Sep 29, 20261
Sep 28, 20261
Sep 27, 20261
Sep 26, 20261
Sep 25, 20261
Sep 24, 20261
Sep 23, 20261
Sep 22, 20261
Sep 21, 20261
Sep 20, 20261
Sep 19, 20261
Sep 18, 20261
Sep 17, 20261
Sep 16, 20261
Sep 15, 20261
Sep 14, 20261
Sep 13, 20261
Sep 12, 20261
Sep 11, 20261
Sep 10, 20261
Sep 9, 20261
Sep 8, 20261
Sep 7, 20261
Sep 6, 20261
npm weekly downloads

25+11 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202625
Dec 4, 202633
Dec 3, 202650
Dec 2, 202650
Dec 1, 202652
Nov 30, 202653
Nov 29, 202644
Nov 28, 202637
Nov 27, 202635
Nov 26, 202623
Nov 25, 202620
Nov 24, 202621
Nov 23, 202620
Nov 22, 202622
Nov 21, 202624
Nov 20, 202622
Nov 19, 202622
Nov 18, 202636
Nov 17, 202641
Nov 16, 202643
Nov 15, 202649
Nov 14, 202649
Nov 13, 202662
Nov 12, 202675
Nov 11, 202666
Nov 10, 202660
Nov 9, 202679
Nov 8, 202676
Nov 7, 202685
Nov 6, 2026388
Nov 5, 2026371
Nov 4, 2026366
Nov 3, 2026365
Nov 2, 2026346
Nov 1, 2026344
Oct 31, 2026341
Oct 30, 202620
Oct 29, 202617
Oct 28, 202616
Oct 27, 202616
Oct 26, 202614
Oct 25, 202612
Oct 24, 20262
Oct 23, 20262
Oct 22, 20262
Oct 21, 20262
Oct 20, 20261
Oct 19, 20261
Oct 18, 20261
Oct 17, 20262
Oct 16, 20263
Oct 15, 20264
Oct 14, 20267
Oct 13, 20267
Oct 12, 20269
Oct 11, 202611
Oct 10, 202616
Oct 9, 202623
Oct 8, 202627
Oct 7, 202626
Oct 6, 202626
Oct 5, 202624
Oct 4, 202622
Oct 3, 202619
Oct 2, 202618
Oct 1, 202616
Sep 30, 202620
Sep 29, 202629
Sep 28, 202629
Sep 27, 202629
Sep 26, 202633
Sep 25, 202627
Sep 24, 202624
Sep 23, 202622
Sep 22, 202622
Sep 21, 202622
Sep 20, 202623
Sep 19, 202617
Sep 18, 202617
Sep 17, 202621
Sep 16, 202619
Sep 15, 202610
Sep 14, 202612
Sep 13, 202610
Sep 12, 202612
Sep 11, 202612
Sep 10, 202616
Sep 9, 202616
Sep 8, 202616
Sep 7, 202614
Sep 6, 202614

Each point is npm's rolling 7-day download count.

Health Score

54/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/938831442-root.svg)](https://payloaddirectory.dev/plugins/938831442-root)
HTML
<a href="https://payloaddirectory.dev/plugins/938831442-root"><img src="https://payloaddirectory.dev/badge/938831442-root.svg" alt="Payload Directory"></a>
Updated Oct 28, 2026Created Feb 25, 2025Published Oct 28, 2026

README

Payload Files Proxy

Small Payload CMS plugin to fetch missing media files from an origin site during local development, inspired by Drupal's stage_file_proxy approach.

Use this when you do not want to sync a large uploads folder locally but still need media files to appear in pages and the admin UI.

Requirements and compatibility

  • Node.js ^22.23.4 || >=24.22.1 and Payload CMS ^3.92.0.
  • The development application uses Payload 3.92.0, Next.js 15.4.11, and React / React DOM 19.1.2. Earlier Payload and Node versions are no longer supported by this package.

Install

npm install payload-files-proxy
# or
pnpm add payload-files-proxy
# or
yarn add payload-files-proxy

Quick Start

import path from 'path'
import { buildConfig } from 'payload'
import { payloadFilesProxy } from 'payload-files-proxy'

export default buildConfig({
  collections: [
    {
      slug: 'media',
      upload: {
        staticDir: path.resolve('./uploads'),
      },
    },
  ],
  plugins: [
    payloadFilesProxy({
      mediaCollectionSlug: 'media',
      mediaDirectory: path.resolve('./uploads'),
      originUrl: 'https://your-production-site.com',
      disabled: process.env.NODE_ENV === 'production',
    }),
  ],
})

Configuration

payloadFilesProxy receives:

  • mediaCollectionSlug?: string
    • Slug used to find the upload collection in config.collections.
    • If omitted, not found, or not an upload collection, no proxy handler is added.
  • mediaDirectory: string (required by type)
    • Retained for compatibility; it does not determine where files are written.
    • Payload's runtime upload.staticDir is used, falling back to the collection slug.
  • originUrl: string
    • HTTP(S) origin used with the requested Payload file URL pathname. The origin's path, query, and fragment are ignored.
  • disabled?: boolean
    • If true, plugin is a no-op and config is returned unchanged.

Runtime Behavior

The plugin appends a file handler without replacing existing handlers. Payload checks read access before calling it. Document reads do not download files: on a file request, the handler checks the runtime local upload directory and fetches only a missing requested file. Payload then serves the local file, including its normal range handling. Image variants are fetched individually when requested.

Downloads are limited to 50 MiB and 15 seconds, require HTTP 200, and reject redirects. Completed downloads are published without overwriting an existing file; concurrent requests in the same process share a download. Failed downloads return HTTP 502 and are not cached.

Important Limitations

  • Requests are anonymous; authenticated origins and redirects are not supported. The origin must serve the same Payload file pathname.
  • Configure only a trusted origin: the server makes outbound requests to it. Do not expose this development proxy in production. Downloaded content is trusted and is not scanned or validated as an image.
  • Payload's read access controls apply, but boolean public read access can permit requests for filenames without a matching database document. Restrict access and the origin accordingly.
  • Local storage must be enabled. The destination is created if necessary and must be writable; storage adapters or handlers that return a response before this handler take precedence.
  • Deduplication is process-local. Existing local files are never refreshed, and the 50 MiB limit is buffered in memory.

Development vs Production

  • Local/dev: enable plugin to auto-pull missing files on demand.
  • Production: disable plugin (disabled: true or NODE_ENV guard).

Troubleshooting

  • Files are not downloaded:
    • confirm mediaCollectionSlug matches your upload collection and read access permits the request
    • confirm the requested pathname is reachable on originUrl without redirects or authentication
    • confirm Payload's local upload directory is writable and local storage is enabled
    • check server logs for origin failures, the size limit, or timeout

Development and tests

The dev/ directory contains the Payload development application. Development requires pnpm 11 (the project pins pnpm 11.25.0). Dependency install scripts are allowed only for sharp. Integration tests use Vitest, an isolated temporary SQLite database, and a local HTTP origin; they do not need production services.

pnpm install
DATABASE_URI=file:./dev/local.db PAYLOAD_CONFIG_PATH=./dev/payload.config.ts pnpm dev

Open http://localhost:3000/admin. The SQLite URI selects a local database; choose a different file if you want an isolated database. PAYLOAD_CONFIG_PATH points Next.js to the development Payload configuration. To regenerate the admin import map after changing components, run:

DATABASE_URI=file:./dev/local.db PAYLOAD_CONFIG_PATH=./dev/payload.config.ts pnpm dev:generate-importmap

The development configuration uses an external origin (https://inet2you.itfumh.es); missing files can only be fetched if that origin is reachable and serves the requested paths. Startup and tests do not require production services.

pnpm test
pnpm test:watch

Contributing

PRs are welcome. If behavior changes, document migration notes clearly in the README.

License

MIT

Acknowledgements

Inspired by Drupal's stage_file_proxy module and similar on-demand media proxy patterns.

Similar plugins