-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response.redirect is not a function #39
Comments
Thanks for the bug report. Give me a day or two to think about this. Intuitively, this should be supported. However, I just expose Request / Response as it’s provided by node-fetch, who has explicitly mentioned that it isn’t supported.
Would you mind opening the ticket in that repo / post back with why they aren’t supporting it?
If for whatever reason, node-fetch won’t support it, then I’ll accept a pr for the same
…On Tue, Mar 3 2020 at 3:23 PM, Raul Stelescu < ***@***.*** > wrote:
I`d like to be able to test the redirect functionality locally (as dummy
test at least), but the Response.redirect function is not defined.
Do you have any plans on supporting it ?
const handler = async function ( request ) { return Response. redirect ( '
some_url ' , 200 ); }; addEventListener ( ' fetch ' , async function ( event
) { event. respondWith ( handler ( event. request )); });
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub (
#39?email_source=notifications&email_token=AAAIPOVGRJSWJTILJLOJDYLRFTHS3A5CNFSM4LAGUYXKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IR63K4A
) , or unsubscribe (
https://github.com/notifications/unsubscribe-auth/AAAIPOUNB6R5R5MM7TAD5ILRFTHS3ANCNFSM4LAGUYXA
).
|
node-fetch doesn't have it supported but isomorphic-fetch does. const redirectStatuses = [301, 302, 303, 307, 308];
if (!Response.redirect) {
Response.redirect = function(url, status= 302) {
if (redirectStatuses.indexOf(status) === -1) {
throw new RangeError(`Invalid status code: ${status}`);
}
return new Response(null, { status: status, headers: { location: url } });
}
} I think an upstream PR would be more appropriate. |
mrbbot
added a commit
to mrbbot/cloudflare-worker-local
that referenced
this issue
Dec 16, 2020
Adds Web Streams API to worker context, and switches to the titelmedia fork of node-fetch which uses Web Streams instead of NodeJS ones. Also closes issue gja#39, as @titelmedia/node-fetch implements Response.redirect.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I`d like to be able to test the redirect functionality locally (as dummy test at least), but the Response.redirect function is not defined.
Do you have any plans on supporting it ?
The text was updated successfully, but these errors were encountered: