Search by

apie / javascript-cdn

pjordaan

Composer package of the apie library: javascript cdn

Package info

github.com/apie-lib/javascript-cdn

pkg:composer/apie/javascript-cdn

Statistics

Installs: 26

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-12-02 15:34 UTC

This package is auto-updated.

Last update: 2026-12-02 15:39:52 UTC


README

javascript-cdn

Latest Stable Version Total Downloads Latest Unstable Version License PHP Composer

PHP Composer

This package is part of the Apie library. The code is maintained in a monorepo, so PR's need to be sent to the monorepo

Documentation

This PHP package provides a same-origin proxy for JavaScript packages served by jsDelivr. It registers a global GET /npm/{path} route and proxies valid npm package paths to https://cdn.jsdelivr.net/npm/.

For example, /npm/@ionic/core@7/dist/ionic/ionic.esm.js proxies the corresponding jsDelivr asset. The package path, version, and file path are validated; the upstream host is fixed to jsDelivr.

Successful responses for versioned package paths are cached for 2 years. Paths using the latest version tag are cached for 10 minutes. Redirects from the CDN are cached the same way and rewritten to the same-origin /npm/ route (redirects to other hosts return 502). Other error responses are not cached. Versioned responses are sent with Cache-Control: public, max-age=63072000, immutable so browsers never revalidate them.

Fake packages

By default, fake packages are read from the package's apie-cdn/ directory. To use a different directory, pass it as the third constructor argument to JavascriptCdnProxy. Files under that directory override jsDelivr files using the same path structure. For example:

fake-packages/
└── apie-stacktrace/
    └── 0.1.6/
        └── dist/
            └── apie-stacktrace/
                └── apie-stacktrace.esm.js

The file above is returned for /npm/apie-stacktrace@0.1.6/dist/apie-stacktrace/apie-stacktrace.esm.js; requests without a matching local file are proxied to jsDelivr.

This package is PHP-only and does not change the CDN URLs currently emitted by apie/html-builders or the layout packages.