mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-11-12 22:29:53 -06:00
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
16 lines
814 B
TypeScript
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();
|
|
}
|