[Content]: Middleware examples use the pre-3.0 `(request, next)` shape; start mode now calls `(event, next)` and `next(request)` throws
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
調査の方向性
指定されたページのミドルウェアの例から始めます。building-apps/middleware-and-api-routes、guides/protected-routes、building-apps/sessions-and-auth、reference/vite-plugin-solid/start、reference/filesystem-routing/api の例を確認してください。シグネチャを solid-v2/fullstack テンプレートの src/middleware.ts および報告された 3.0.1 の型と比較します。古くなった例と説明を現在の API に合わせて更新します。完了条件は、指定された例で request-first 形式や next(request) が使われなくなることです。
索引モデルが issue の本文から書いたものです。
説明
📚 Subject area/topic
Building apps (Middleware and API routes), Guides, Reference (@solidjs/vite-plugin, filesystem-routing)
📋 Page(s) affected (or suggested, for new content)
Examples break when copied:
- https://docs.solidjs.com/building-apps/middleware-and-api-routes ("Add a middleware": the
Middlewaretype,requireHttps,securityHeaders, and "Pass aRequesttonext(request)to replace the request") - https://docs.solidjs.com/guides/protected-routes ("Middleware for whole sections":
requireAccountSessionreadsrequest.url)
Works at runtime, but the type annotation is the old shape:
- https://docs.solidjs.com/building-apps/sessions-and-auth ("Authenticate once in middleware":
attachCustomer(_request: Request, next)) - https://docs.solidjs.com/reference/vite-plugin-solid/start (
### middleware: theMiddlewaretype)
Signature from an older release:
- https://docs.solidjs.com/reference/filesystem-routing/api (written from
v0.2.1; in 0.5.0createAPIHandlerreturns(input: Request | { request: Request }, next) => Promise<Response>)
📋 Description of content that is out-of-date or incorrect
Since @solidjs/vite-plugin 3.0.0-next.48 (CHANGELOG 1702a19, marked BREAKING), start-mode middleware is event-first:
// @solidjs/vite-plugin 3.0.1, dist/types/src/request-event.d.ts
export type StartMiddleware = (
event: StartRequestEvent,
next: () => Promise<Response>
) => Response | Promise<Response>;
The request is event.request, and next() takes no arguments. To substitute the request, assign event.request before calling next(). The solid-v2/fullstack template's src/middleware.ts uses this shape (satisfies StartMiddleware[]).
The pages above still document the request-first shape, (request: Request, next: (request?: Request) => …), and say to call next(request). Copying them breaks the app.
Checked in dev with solid-js / @solidjs/web 2.0.3, @solidjs/vite-plugin 3.0.1, vite 8.3.8. I wrote a middleware exactly to the documented type and registered it with start.middleware:
export default async (request: Request, next: (request?: Request) => Response | Promise<Response>) => {
console.log("[mw] request.url =", (request as any).url);
return next(request);
};
The first argument is the event (request.url logs undefined), and every page answers 500 with:
[@solidjs/vite-plugin] start.middleware: next() takes no arguments. Middleware receives the request event — (event, next) — so to substitute the request, assign event.request = newRequest before calling next().
The guide's requireHttps and the protected-routes requireAccountSession would also fail at new URL(request.url) before they reach next().
Proposed fix: switch these examples to (event, next) with event.request, type the middleware module as StartMiddleware[] like the template does, and replace the next(request) paragraph with "assign event.request before calling next()". I'm happy to send a PR, one page or all of them, whichever you prefer.
🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)
Local steps: pnpm create solid@latest -t basic --solid --ts --ssr (rename the generated start: { node: true } to nodeServer: true), add middleware: './src/middleware.ts' to start, put the middleware above in src/middleware.ts, run pnpm dev, and open /.
- 主要言語
- MDX
- スター
- 291
- フォーク
- 369
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 39
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
solidjs/solid-docs のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
solidjs/solid-docs#1713 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
solidjs/solid-docs#1635 ·
メンテナーはふだん 1 日以内に返信
-
[Content]: Cloudflare Workers対応中かも @Janani-bn が 52 日前に担当しました。 オープンgood first issue solid solidstart
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
solidjs/solid-docs#1522 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Content]: v2 Store documentation is unclear on class instances対応中かも @LadyBluenotes が 14 日前に担当しました。 オープンpending review
solidjs/solid-docs#1687 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Content]: Add a concrete DOM-binding example to fine-grained reactivity再び着手できるかも @LadyBluenotes が 85 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンpending review
solidjs/solid-docs#1637 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
solidjs/solid-docs の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
needs discussion
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openfga/openfga.dev#1436 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
Awesome-Embedded-Learning-Studio/Tutorial_AwesomeModernCPP#335 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
-
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100