Skip to content

gateway: a directory under a site's /_decdn/ redirects to a URI the gateway refuses #2818

Done

Description

@thiras

Component

decdn gateway: a site origin's /_decdn/ paths (Gateway::entry and the /_decdn/ branch of the site handler in crates/cli/src/commands/gateway.rs).

Version

v0.3.0 and main (e7e67e6, v0.3.1).

Steps to reproduce

  1. Publish a bundle <h> with an entry docs/index.html and no entry docs.
  2. From a page on any site origin, issue a same-origin request (not a navigation) for /_decdn/<h>/docs, e.g. fetch("/_decdn/<h>/docs").
  3. Follow the redirect.

Expected behavior

The request ends at docs/index.html, as /docs does on <h>'s own site (a_site_directory_serves_its_index).

Actual behavior

  1. entry() finds no entry docs, but finds docs/index.html. Under Present::Site it answers 302 with the relative Location: docs/. The comment there says this "holds under /_decdn/ too".
  2. The browser resolves that to /_decdn/<h>/docs/.
  3. The /_decdn/ branch parses the rest as decdn:<h>/docs/ directly. That branch has no "a directory serves its index.html" step: the site's own paths get one (path.ends_with('/') → {path}index.html), but /_decdn/ does not.
  4. decode_path refuses the trailing empty segment ("empty segment (a leading, trailing or doubled / inside the path)"), so the gateway answers 400.

A second problem: the relative Location drops the query. So /_decdn/<h>/docs?ns=7 lands on /_decdn/<h>/docs/ without its ?ns=7 routing hint.

Logs

n/a. a_site_directory_serves_its_index (gateway/tests.rs) covers /docs on the site's own origin, and no test covers a directory under /_decdn/.

Possible fixes

Either:

  • Map a trailing / under /_decdn/<h>/…/ to …/index.html, as the site's own paths do, before parsing. Also keep the query on the redirect (Location: docs/?ns=7).
  • Or, under /_decdn/, redirect a directory straight to <dir>/index.html with the query, so the target is a URI the parser accepts.

Notes

@decdn/client is unaffected when it verifies: it reads the manifest and fetches docs/index.html (decdn/sdk-typescript#21). It is affected with verify: false on a site page: get("decdn:<h>/docs", { verify: false }) goes through /_decdn/ and gets the 400. The SDK's fake gateway mirrors the redirect as it is today, so the fix needs a matching sdk-typescript change to the fake (and a contract test once the fixture has a directory entry).

Activity

  1. added
    kind:bug
    area:cli
    on Nov 1, 2026
  2. moved this from Backlog to In progress in deCDNon Nov 23, 2026
  3. moved this from In progress to Done in deCDNon Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clikind:bug

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions