The Sec-Fetch-Dest header indicates the destination of the request and
can be used to know if the request came from a fetch call or not, among
other things.
// Detect if the request came from a fetch call and return // json, otherwise return a redirect exportasyncfunctionaction({ request }: ActionFunctionArgs) { letdest = fetchDest(request); if (dest === "empty") returnjson(data) returnredirect(destination) }
The Sec-Fetch-Dest header indicates the destination of the request and
can be used to know if the request came from a fetch call or not, among
other things.
// Detect if the request came from a fetch call and return // json, otherwise return a redirect exportasyncfunctionaction({ request }: ActionFunctionArgs) { letdest = fetchDest(request); if (dest === "empty") returnjson(data) returnredirect(destination) }
Returns the value of the
Sec-Fetch-Dest
header.The
Sec-Fetch-Dest
header indicates the destination of the request and can be used to know if the request came from afetch
call or not, among other things.