Skip to content

override_fetch

override_fetch(request, ctx) completely replaces SpyWeb’s internal HTTP client. Use this when you need custom fetching, like launching a Chrome instance via CDP or using a proxy rotater.

function override_fetch(request, ctx) -> table

Same as before_fetch.

Return Effect
response object A standard response table ({ status = 200, body = "...", url = "..." }). Output acts exactly like a native fetch result and will still pass through after_fetch if defined.
{ error = "msg" } Simulate a network failure
nil or false Causes a pipeline error (“must return a response table”). Unlike other hooks, nil/false does NOT mean skip — this hook must always return a response table or an error table.
function override_fetch(request, ctx)
local res, err = http_get("http://my-renderer.local/?url=" .. request.url)
if not res then
return { error = "renderer request failed: " .. err.error }
end
return {
status = res.status,
url = request.url,
body = res.body,
headers = res.headers
}
end
  • before_fetch - Modify the request (but still use built-in fetch)
  • after_fetch - Process the response after fetching