URL is not in Response Object if the response is an opaqueredirect
As per title. If the Response is a opaqueredirect type then the URL is not set correctly in the Response object.
Within Cloudflare a Response object always has the URL set.
Due to - https://github.com/cloudflare/miniflare/blob/master/packages/core/src/standards/http.ts#L810
It'd be best if we could have the body as per Cloudflare behaviour but it appears that isn't possible based off the comments.
Could we manually set the URL on the object using Object.defineProperty or probably something like Response.redirect would be better suited
https://developer.mozilla.org/en-US/docs/Web/API/Response/redirect
Hey! 👋 Thanks for raising this and apologies for the delayed response. We could probably do this by copying the urlList from the internalResponse of the opaqueredirect to the new non-opaque one, kinda like we're doing here: https://github.com/cloudflare/miniflare/blob/b887877810a745f2a458d20da0a3dbd9f8a58cf4/packages/core/src/standards/http.ts#L801
Looks like undici no longer returns opaqueredirect Responses when redirect is set to manual as of https://github.com/nodejs/undici/pull/1210. Would you be able to try using the latest version of Miniflare?
Hey @mrbbot. I think this might be related, but when ever I get a 30X response, undici is terminating. It only when redirect: 'manual' is set. Using [email protected].
[mf:err] GET /: TypeError: terminated
[mf:err] Cause: AbortError: The operation was aborted
I tried updating to the latest undici locally and that didn't seem to do anything. Any thoughts?
A little more debugging reveals that this only happens when the 30X response has a non null body. I worked around it by checking for location header and nulling out the body, but this is definitely different behavior than cf workers.