Files
sendou.ink/app/features/dev-tools/dev-tools-utils.server.ts
Kalle f7372324fe
Some checks failed
E2E Tests / e2e (push) Has been cancelled
Tests and checks on push / run-checks-and-tests (push) Has been cancelled
Updates translation progress / update-translation-progress-issue (push) Has been cancelled
E2E Tests / publish-docs-screenshots (push) Has been cancelled
Dev tools (#3471)
2026-10-25 11:43:36 +02:00

16 lines
814 B
TypeScript

import { IS_DEV_BUILD } from "~/utils/dev-build";
import { forbidden, notFound } from "~/utils/remix.server";
/**
* Every dev tools loader and action starts with this. The routes are only registered on the dev server, this
* is the second lock: a 404 outside a dev build, and a 403 for a request another site's page made the browser
* send (the dev server listens on localhost, which any open tab can reach). Requests from the toolbar are
* same-origin, links opened from a terminal and CLI requests carry no `Sec-Fetch-Site` at all or `none`.
*/
export function requireDevTools(request: Request) {
if (!IS_DEV_BUILD || process.env.NODE_ENV === "production") notFound();
const fetchSite = request.headers.get("Sec-Fetch-Site");
if (fetchSite === "cross-site" || fetchSite === "same-site") forbidden();
}