Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

12 linesCodeBlameRaw
1import { redirectDocument, type MiddlewareFunction } from "react-router";
2import { needsBuildRefresh } from "./build-version";
3import { pageOf } from "./confirm-gate";
4
5export const buildVersionMiddleware: MiddlewareFunction<Response> = async ({ request }, next) => {
6 if (needsBuildRefresh(request, import.meta.env.G1T_BUILD_ID)) {
7 const url = new URL(request.url);
8 url.searchParams.delete("_routes");
9 throw redirectDocument(pageOf(url.pathname) + url.search, { headers: { "cache-control": "no-store" } });
10 }
11 return next();
12};