cloudflare/workers-docs

Document that Response.redirect() is a static method

harrishancock opened this issue · 2 comments

In particular, the following won't work:

let response = new Response(...)
return response.redirect(...)

(it should just be Response.redirect())

See https://community.cloudflare.com/t/redirect-method-in-response-object-is-not-exists-but-the-documentation-says-it-exists/179953

@harrishancock I was reviewing my workers code, and then developers.cloudflare.com and haven't found anything other than:

return Response.redirect(url, status);

Are you referring somewhere specific?

Hi @adaptive, our documentation here is misleading: https://developers.cloudflare.com/workers/reference/apis/response/

Specifically, we seem to imply that Response.clone() and Response.redirect() are both callable in the same way, whereas we should really call out that Response.redirect() may only be called on the constructor itself. (The link to the community forum shows an example of someone who was confused by this implication.)