Choosing Between @nuxtjs/proxy and a Custom Axios HTTPS Agent for Consistent TLS Validation in Nuxt 3
29K reputation · 08 Mar 2025, 13:58 UTC
Goal: Ensure that all outbound HTTP(S) requests from a Nuxt 3 application—whether they are routed through the @nuxtjs/proxy middleware or initiated directly via an axios instance—use the same DNS resolution strategy and TLS certificate validation settings.
Constraint: The @nuxtjs/proxy module forwards requests using Node's http-proxy and does not automatically apply a custom axios httpsAgent, so proxy‑bypassed requests inherit the system’s default agent while direct axios calls can use a custom agent with options such as rejectUnauthorized or a custom lookup function.
Uncertainty: It is unclear whether the proxy can be configured to honor a custom httpsAgent, or whether developers must avoid the proxy and manage agents manually in each composable or plugin to achieve uniform validation.
- Can @nuxtjs/proxy be made to use a custom axios httpsAgent for proxied requests without losing its automatic request‑forwarding behavior?
- If the proxy cannot propagate the agent, what are the trade‑offs between relying exclusively on the proxy for all outbound calls and duplicating agent configuration in every axios instance?
- Is there a recommended pattern that provides consistent DNS lookup and TLS validation while still benefiting from the proxy’s automatic routing?