Skip to content

Route path-addressed server function calls - #332

Draft
ryansolid wants to merge 2 commits into
nextfrom
server-function-path-addressing
Draft

Route path-addressed server function calls#332
ryansolid wants to merge 2 commits into
nextfrom
server-function-path-addressing

Conversation

@ryansolid

Copy link
Copy Markdown
Member

Summary

Downstream adoption of solidjs/solid#3076: a server function call's address is now <endpoint>/<id> with arguments in the query, and the X-Server-Function-Id header and ?id= fallback left the wire.

  • Dev middleware (server-functions/index.ts): the endpoint gate matched the pathname exactly, so path-addressed calls fell through to SSR. It now matches by mount prefix (exact or endpoint + '/'), for both the base-prefixed and base-stripped forms. The module-preload function id comes from the path segment; the header and ?id= forms stay as fallbacks for a client runtime older than the addressing change.
  • Generated dispatch gate (ssr/index.ts): the emitted dispatchRequest composed server functions only at pathname === endpoint; it now prefix-matches the same way. A bare-mount request still routes to the runtime handler, which answers the 404 — a misaddressed post fails through the endpoint rather than rendering a page at it.

Draft until

@solidjs/web publishes the addressing change (anything newer than 2.0.0-rc.3). The plugin change is backward-compatible on its own — exact-match and the fallback id channels keep an older runtime working.

Test plan

  • Verified end-to-end against the fullstack-tanstack template with the solid next runtime linked in: GET-declared reads over /_server/<id> (GET returns data + default no-store, HEAD returns bodyless 200), undeclared reads gated (403/405), and the unscripted no-JS form POST flow (303 + flash cookie) all dispatch through the dev middleware.
  • Cypress example suite once the next @solidjs/web prerelease is published.

Companion PR: solidjs/solid-router#590.

Made with Cursor

solidjs/solid#3076 moved the function id into the path
(`<endpoint>/<id>`), retiring the X-Server-Function-Id header and the
`?id=` query fallback. The dev middleware and the generated
dispatchRequest gate matched the endpoint pathname exactly, so the new
addresses fell through to SSR; both now match by mount prefix (exact or
`endpoint + '/'`). The dev middleware's module-preload id comes from
the path segment, with the header and `?id=` forms kept as fallbacks
for a client runtime older than the addressing change.

Verified end-to-end against the fullstack-tanstack template with the
solid `next` runtime linked in: GET-declared reads (GET and HEAD),
405/403 gating, and the unscripted no-JS form POST flow (303 + flash)
all dispatch through the new addresses in dev.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 027ff50

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/vite-plugin Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Aug 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/vite-plugin@332

commit: 027ff50

…table

Co-authored-by: Cursor <cursoragent@cursor.com>
@ryansolid

Copy link
Copy Markdown
Member Author

Per review: the header/?id= fallbacks in the dev middleware are marked TRANSITIONAL and scoped to the RC window only — they get dropped before the 3.0 stable release. Path addressing is the only wire format from stable on.

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