Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(backend,remix): Tweak ClerkRequest initialization to work-around …
…edge-runtime and undici limitations (#3129) * fix(backend,remix): Tweak ClerkRequest initialization to work-around edge-runtime and undici limitations The usual way to duplicate a request object is to pass the original request object to the Request constructor both as the `input` and `init` parameters, eg: super(req, req) However, this fails in certain environments like Vercel Edge Runtime when a framework like Remix polyfills the global Request object. This happens because `undici` performs the following instanceof check which, instead of testing against the global Request object, tests against the Request class defined in the same file (local Request class). For more details, please refer to: nodejs/undici#2155 https://github.com/nodejs/undici/blob/7153a1c78d51840bbe16576ce353e481c3934701/lib/fetch/request.js#L854 * fix(backend,remix): Tweak ClerkRequest initialization to work-around edge-runtime and undici limitations The usual way to duplicate a request object is to pass the original request object to the Request constructor both as the `input` and `init` parameters, eg: super(req, req) However, this fails in certain environments like Vercel Edge Runtime when a framework like Remix polyfills the global Request object. This happens because `undici` performs the following instanceof check which, instead of testing against the global Request object, tests against the Request class defined in the same file (local Request class). For more details, please refer to: nodejs/undici#2155 https://github.com/nodejs/undici/blob/7153a1c78d51840bbe16576ce353e481c3934701/lib/fetch/request.js#L854
- Loading branch information