X Tutup
Skip to content

Static Assets support folder expansion at root#2120

Merged
joachimvh merged 3 commits intoCommunitySolidServer:mainfrom
bourgeoa:staticAsset
Feb 25, 2026
Merged

Static Assets support folder expansion at root#2120
joachimvh merged 3 commits intoCommunitySolidServer:mainfrom
bourgeoa:staticAsset

Conversation

@bourgeoa
Copy link
Contributor

📁 Related issues

#2119

✍️ Description

What changed

  • Root folder mappings are now automatically expanded to explicit file mappings for safety.
  • Non-root folder mappings preserve dynamic catch-all behavior for runtime file serving.

Why

  • Enables root-level static assets (e.g., mashlib chunks) without mapping / to a folder and hijacking all Solid routes.
  • Root folder mappings were previously unsafe because they would catch ALL requests, including pod resources.
  • Non-root folders preserve existing behavior: new files appear automatically without server restart.

How to use

Simply map a folder to root - it will be expanded automatically:

{
  "@id": "urn:solid-server:default:StaticAssetHandler",
  "@type": "StaticAssetHandler",
  "assets": [
    {
      "@type": "StaticAssetEntry",
      "relativeUrl": "/",
      "filePath": "./node_modules/mashlib/dist/"
    },
    {
      "@type": "StaticAssetEntry",
      "relativeUrl": "/assets/",
      "filePath": "./static/"
    }
  ]
}

In this example:

  • / mapping → expanded to explicit files (/mashlib.js, /841.mashlib.js, etc.)
  • assets/ mapping → keeps catch-all behavior (/assets/anything.js serves from ./static/ at runtime)

Tests

  • Added unit test for automatic root folder expansion.
  • Added unit test verifying non-root folders keep catch-all behavior.

Notes

  • Expansion is non-recursive by design (top-level files only).
  • Zero breaking changes - existing configurations work unchanged.

✅ PR check list

Before this pull request can be merged, a core maintainer will check whether

  • this PR is labeled with the correct semver label
    • semver.patch: Backwards compatible bug fixes.
    • semver.minor: Backwards compatible feature additions.
  • the correct branch is targeted. Patch updates can target main, other changes should target the latest versions/* branch.
  • the RELEASE_NOTES.md document in case of relevant feature or config changes.
  • any relevant documentation was updated to reflect the changes in this PR.

Copy link
Member

@joachimvh joachimvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good solution to your problem. I was wondering why you made it non-recursive? I would think it would be more flexible to make it recursive.

Some minor comments.

@bourgeoa
Copy link
Contributor Author

Your 3 review changes are included.

As to why no recursive ?
I think the main idea is to avoid the risk of over charging root routes. Which was your original implementation
It is always possible to add regular non root StaticAssets folder if needs be.

Copy link
Member

@joachimvh joachimvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@joachimvh joachimvh merged commit b48edf8 into CommunitySolidServer:main Feb 25, 2026
30 checks passed
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.

2 participants

X Tutup