How to bypass TLS / HTTPS / SSL requirements when talking with external APIs in Remix app during local development ? #4059
-
While integrating remix into our stack at work, I ran into challenges with HTTPS/ SSL certs during local development.
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' TLS Workaround -- Per HTTP/S CallUnlike the If you see the code example below, we're passing an import { 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({});
} Related |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
The Remix App Server doesn't support using https, you would have to switch to a custom Express server and then configure SSL on the Express server. Another option is to run a reverse proxy like NGINX before your Remix app and configure SSL there. |
Beta Was this translation helpful? Give feedback.
-
@cliffordfajardo I'm also running into this, and I've tried it with both Did you do sth special / which adapter are you using? I'm not using any adapter but the integrated app server. This is the error: (It's different as I'm using a bundle.crt including the custom root CA cert)
|
Beta Was this translation helpful? Give feedback.
-
Edited original post ↑, Essentially no need to use |
Beta Was this translation helpful? Give feedback.
The Remix App Server doesn't support using https, you would have to switch to a custom Express server and then configure SSL on the Express server.
Another option is to run a reverse proxy like NGINX before your Remix app and configure SSL there.