Skip to content

feat(registry): hosted semver static redirect - #1574

Merged
ricardo-devis-agullo merged 1 commit into
masterfrom
feat/hosted-component-static-redirect
Sep 10, 2026
Merged

feat(registry): hosted semver static redirect#1574
ricardo-devis-agullo merged 1 commit into
masterfrom
feat/hosted-component-static-redirect

Conversation

@ricardo-devis-agullo

@ricardo-devis-agullo ricardo-devis-agullo commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Consumers of a component's bundled static files currently have to know the CDN base URL and the exact version, because oc only registers a static route when running locally.

This adds a hosted-mode route mirroring the local one:

GET /:componentName/:componentVersion/static/*splat -> 302 to CDN file

  • Resolves the version with the same version-handler used for rendering (semver.maxSatisfying over repository.getComponentVersions, i.e. the cached components list, so no self-request and works with metadata adapters).
  • Redirect target is built with repository.getStaticFilePath, so it follows the existing storageOptions CDN on/off toggle.
  • Redirect (not proxy): registry serves no extra bytes, CDN caching preserved.
  • 404 on unknown component, unsatisfiable range, empty/traversal paths, and private files (server.js, dotfiles via isPrivateComponentFile).
  • Purely additive: hosted-only route registered before the generic component routes; local mode unchanged.

Example:
GET /my-component/2.x.x/static/public/scripts/workerScripts.cjs.js
-> 302 https:///components/my-component/2.0.167/public/scripts/workerScripts.cjs.js

Tests: test/unit/registry-routes-component-static.js (34 cases: exact, range, 404s, private-file block, traversal, router registration incl. prefix).

Resolves :componentVersion with the same version-handler used for rendering and 302-redirects :name/:version/static/* to the CDN file, so consumers get a stable URL without knowing the exact version or CDN base. 404 on unknown component, unsatisfiable range, traversal and private files.
@ricardo-devis-agullo
ricardo-devis-agullo merged commit baca733 into master Sep 10, 2026
3 checks passed
@ricardo-devis-agullo
ricardo-devis-agullo deleted the feat/hosted-component-static-redirect branch September 10, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant