Support HTTP(s) agent
- use remix-run/web-std-io
package for fetch
API
#195
Replies: 1 comment
-
Discord Conversation: Sergio
Clifford
Sergio
Clifford
Sergio
Sergio
|
Beta Was this translation helpful? Give feedback.
-
I've been using Remix Auth outside of work just fine, however I ran into a challenge when using it at work when deploying to production.
Scenario
At work, our servers can't make requests to the external internet unless they go through a proxy (ex:
company.proxy.com
).That is to say, when I try to authenticate with my oauth service provider, it fails because the request didn't come from
company.proxy.com
.Other paths considered
@mswjs/interceptors
package, but it doesn't support reading or sendingformData
at this time (reference)remix-auth
at all and implementing authentication in the express server code, if you're on the express template. The downside is you lose out on the niceremix-auth
API's that you can use in yourloader
's.Proposition
Adopt usage of
remix-run/web-std-io
which is the Remix's team's server implementation of thefetch
API (basically it's equivalent tonode-fetch
& undici (in node v18+ runtimes).What would adoption of Request from
remix-run/web-std-io
look like?Use
fetch
,Request
,Response
from@remix-run/web-fetch
directly for server-side files only inremix-auth
.Folks using
remix-auth
could then pass downagent
and the other options from RequestExtraOptionsThe main difference between the
fetch
API that exists in the browser and the one Remix uses is that it supports additional options which only matter or can exist in server runtimes (Ex: passing an HTTP(s) agent only makes sense on server)remix-run/web-std-io
's Request classlib.dom.d.ts
browser's fetch typingsOpen Questions
If this were to happen, the next thing to think about is where to best expose the options object that the user could pass down that.
I'm not sure where the best place would be since, i'm not familiar with entire scope of
remix-auth
The end goal would allow a user to pass down
RequestExtraOptions
from a strategy package and have it ultimately go down toremix-auth
remix-auth
recievesRequestExtraOptions
fromremix-oauth2
remix-oauth2
receivesRequestExtraOptions
options and passes them toremix-auth
RequestExtraOptions
intoremix-auth-{microsoft, supabase .. etc}
Previous Work
The node-fetch & node 18 fetch API mirrors the browser's
fetch
API except it also allows you to pass options which are relevant and only useful on the server. You can pass things like HTTP(s) agents like so:Related
agent
)fetch
APIRequest
class APIBeta Was this translation helpful? Give feedback.
All reactions