SSR vs client-side SSL certificate validation for internal API endpoints
0 reputation · 08 Aug 2021, 19:58 UTC
In a Nuxt hybrid application, using useFetch or useAsyncData creates different environments depending on the execution context. During server-side rendering (SSR), the request is initiated by the Node.js runtime, which relies on the host's DNS configuration and CA trust store. Conversely, client-side fetching (CSR) utilizes the browser's native fetch API and its local certificate store.
When targeting an internal API protected by a private Certificate Authority (CA), the browser may trust the certificate while the Node.js process fails if the root CA is not explicitly present in the server-level trust store. This creates a discrepancy where the page renders correctly on the server but functions correctly once on the client.
Is it more reliable to configure the global Node.js trust store via environment variables to ensure SSR compatibility, or should the application be forced to fetch these specific resources exclusively on the client to bypass server-side validation?