feat: refresh update status on every dev reload
This commit is contained in:
@@ -1,11 +1,20 @@
|
|||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from 'next/server';
|
||||||
import { loadState } from '@/lib/version-check';
|
import { checkOnce, loadState } from '@/lib/version-check';
|
||||||
|
|
||||||
// Public endpoint that returns the latest cached update status. Fed by the
|
// Public endpoint that returns the latest cached update status. Fed by the
|
||||||
// background scheduler started in instrumentation.node.ts; we never trigger
|
// background scheduler started in instrumentation.node.ts; in production we
|
||||||
// a fresh upstream fetch from this route, so an unauthenticated client cannot
|
// never trigger a fresh upstream fetch from this route so an unauthenticated
|
||||||
// use it to amplify traffic to the version server.
|
// client can't use it to amplify traffic to the version server.
|
||||||
|
//
|
||||||
|
// In development we force a fresh fetch on every hit so changes to the
|
||||||
|
// version server's overrides take effect on the next page reload instead of
|
||||||
|
// requiring a dev-server restart. The 5s upstream timeout in fetchStatus
|
||||||
|
// caps the worst-case latency added to a dev reload.
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
await checkOnce({ reason: 'dev-reload' });
|
||||||
|
}
|
||||||
|
|
||||||
const state = await loadState();
|
const state = await loadState();
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user