sergiodxa / remix-auth-oauth2

A OAuth2Strategy for Remix Auth
https://sergiodxa.github.io/remix-auth-oauth2/
MIT License
150 stars 56 forks source link

Unusable behind proxy #76

Closed gabriel-le closed 3 months ago

gabriel-le commented 10 months ago

The authentication process times out when the server is behind a proxy.

A possible fix would be to let developers override the fetch function and provide their own.

sergiodxa commented 10 months ago

It uses the global fetch function, so you could override it globally.

let originalFetch = globalThis.fetch;
globalThis.fetch = newFetchCompatibleWithProxy;

Also a fetch call only happens once in the code, here https://github.com/sergiodxa/remix-auth-oauth2/blob/593e397df11d3678fa4ad02935b44316ad2e5259/src/index.ts#L416-L420, and fetchAccessToken (the method where that happens) is marked as protected, so if you create a sub-class of OAuth2Strategy you could override fetchAccessToken to provide your own version using a fetch compatible with a proxy.

gabriel-le commented 10 months ago

Good to know, thanks for the tip!