Redirect method in Response object is not exists, but the documentation says it exists

The documentation says that Response object have redirect method. But if you access the Response.redirect method, your worker will raise an exception.

This minimal code to reproduce the issue:

addEventListener("fetch", event => {
        (() => {
            try {
                const response = new Response();
            } catch (err) {
                return new Response(err.stack || err);
            return new Response("test");

if you deploy the worker above and perform GET request, you will error like the following:

TypeError: (intermediate value).redirect is not a function
    at worker.js:1:995
    at worker.js:1:1098

Iā€™m not sure if this is a bug or outdated documentation.

A static method (if that existed in Javascript :wink:)

1 Like

Good catch @bayualsyah! Filed to fix it.

Try Response.redirect("") instead.

@sandro @harris Ah I see. Thanks! :pray: