Use feature flag in Next 16 Cache Component API GET route

オープン
#541 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
活発
技術スタック
next.js, typescript
領域
api, backend

調査の方向性

Start by reproducing the issue in the Next 16 API route GET method with Cache Components enabled, using the feature flag imported from lib/flags. Compare direct flag access with access from a cached data call; done when the route can read the flag without the headers() prerendering error.

索引モデルが issue の本文から書いたものです。

説明

I am trying to use a feature flag in a Next 16 app that has Cache Components enabled. I am trying to access the feature flag in an API routes GET method and receiving the error below. If I move the flag request into a cached data call, then it complains that headers() is accessed.

What is the correct way to handle this?

Error:

Error: During prerendering, `headers()` rejects when the prerender is complete. Typically these errors are handled by React but if you move `headers()` to a different context by using `setTimeout`, `after`, or similar functions you may observe this error and you should handle it in that context. . This occurred at route "/api/route-name"

Example Code:

import { flag } from 'lib/flags';

export async function GET(req: NextRequest): Promise<Response> {
  const flagValue = await flag();
}
主要言語
TypeScript
スター
629
フォーク
93
平均マージ
1日 15分
マージ済み PR(30日)
25

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vercel/flags のほかの issue

vercel/flags の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。