Use Sec-Fetch-Mode to check instead

This commit is contained in:
Ayane Satomi 2023-10-23 13:53:35 +00:00
parent 69e462f758
commit 438712c05b

View file

@ -22,8 +22,8 @@ export const handler: Handlers = {
const headers = req.headers;
// check if useragent is a browser
// we can use the Sec-Ch-Ua header but it's not supported by all browsers
if (!headers.get("sec-ch-ua")) {
// we can use the Sec-Fetch-Mode header but it's not supported by all browsers
if (!headers.get("sec-fetch-mode")) {
return new Response("", {
status: 403,
statusText: "Forbidden",
@ -89,8 +89,8 @@ export const handler: Handlers = {
const headers = req.headers;
// check if useragent is a browser
// we can use the Sec-Ch-Ua header but it's not supported by all browsers
if (!headers.get("sec-ch-ua")) {
// we can use the Sec-Fetch-Mode header but it's not supported by all browsers
if (!headers.get("sec-fetch-mode")) {
return new Response("", {
status: 403,
statusText: "Forbidden",