-
We're using a dev-machine local proxy to upgrade local dev-server non-HTTPS calls to HTTPS calls based on self-signed certificates. When using fetch() from within Remix, a The standard way to resolve this error in node-fetch would be to supply a custom This is probably expected behavior, because afaics Remix just exposes the Web Fetch API, which of course has no concerns as changing its agent... any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
After doing some more digging:
|
Beta Was this translation helpful? Give feedback.
-
I recently found out that Remix does expose the TLS Workaround -- Per HTTP/S Callimport { fetch, Request, json, LoaderArgs } from '@remix-run/node';
import https from 'https'; // OR import 'http' if your remix server is running on http
export async function loader({ params }:LoaderArgs) {
// Example 1
const response1 = await fetch('example-api.com/people',{
agent: new https.Agent({ rejectUnauthorized: true, requestCert: false})
})
const data1 = await response1.json();
// Example 2
const response2 = new Request('example-api.com/people', {
agent: new https.Agent({ rejectUnauthorized: true, requestCert: false})
})
const data2 = await response2.json();
return json({});
} TLS Workaround -- Application Wide SettingI don't claim that this is the best solution, but its a good way to get unblocked to continue building during development. // Package.json
"scripts": {
"dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 remix dev",
}, or // entry.server.ts
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0' References / Related |
Beta Was this translation helpful? Give feedback.
After doing some more digging: