Open Closed

Angular SSR requests failing for secured ABP OpenIddict APIs (works in browser and Postman) #10588


User avatar
0
imranStem created

Description

We have integrated our shop application with Angular SSR (Server-Side Rendering). In this setup, certain API requests are executed on the server (Node.js) during the rendering phase, and the data is transferred to the client.

If a server-side request fails, the application falls back to client-side execution, and the data (e.g., categories) loads successfully in the browser.

Backend Configuration

The backend gateway is implemented using the ABP Framework with OpenIddict but end point is opened.

Observations SSR runs in a Node.js environment, not in the browser Browser requests automatically include authentication (cookies or tokens) SSR requests may not include the same authentication context If SSR fails, the client-side fallback works correctly and loads the data

Suspected Causes

We are not certain about the exact root cause, but possible reasons include:

Authentication not being forwarded during SSR Missing cookies or access tokens in server-side requests Differences in request context SSR requests may not include required headers (Authorization / cookies) CORS or origin-related differences Requests originating from Node.js instead of browser (Possibly) SSL / certificate-related configuration Only if backend enforces stricter validation for non-browser clients

Steps to Reproduce Configure Angular application with SSR Connect it to an ABP backend secured with OpenIddict Call a API during SSR rendering Observe failure in SSR Access the same API via browser/Postman → works successfully

Expected Behavior

SSR should be able to call secured APIs when properly authenticated or should have a recommended pattern for handling such scenarios.

Actual Behavior SSR API call fails with an exception Client-side fallback successfully retrieves and displays data

Error in node.js

UNABLE_TO_VERIFY_LEAF_SIGNATURE

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

2 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • UNABLE_TO_VERIFY_LEAF_SIGNATURE is not an ABP/OpenIddict authentication failure. It’s a Node.js TLS trust-chain validation error during SSR when Node calls your ABP backend over HTTPS and cannot validate the server certificate chain (very common with missing intermediate certs, corporate TLS interception, or self-signed/internal CA certs).
      That’s why it can “work in browser/Postman” (they often use OS trust store / may have different trust behavior) but fail in SSR (Node uses its own CA bundle).

    • Fix it on the certificate / chain side (recommended):

      1. Ensure your API/AuthServer HTTPS endpoint presents the full certificate chain (server cert + intermediates).
        • If you’re using Nginx/Apache/IIS/reverse-proxy, configure it to serve the full chain (often called fullchain.pem on Let’s Encrypt setups).
      2. If you have an internal CA, add that CA to the machine trust and/or supply it to Node (next bullet).
    • Fix it on the SSR Node runtime side (when you must trust a private CA):

      1. Export the issuing CA (or corporate proxy CA) as a PEM file, e.g. corp-root-ca.pem.
      2. Start SSR with:
        • NODE_EXTRA_CA_CERTS=/path/to/corp-root-ca.pem
        • (Optional for debugging only) NODE_DEBUG=tls This makes Node trust that CA and resolves UNABLE_TO_VERIFY_LEAF_SIGNATURE without disabling TLS checks.
    • Avoid this “quick fix” in production (insecure):

      • Setting NODE_TLS_REJECT_UNAUTHORIZED=0 or using an HTTPS agent with rejectUnauthorized: false will bypass TLS verification entirely. It may “make it work”, but it weakens security and should not be used beyond local debugging.
    • After TLS is fixed, if the API is actually secured and SSR must call it authenticated:

      • SSR must forward the same auth context (cookies / bearer token) from the incoming browser request to your ABP backend when rendering. This is an Angular SSR integration concern; ABP will only accept what the request contains.

    Links (verified):

    • https://abp.io/docs/latest/modules/openiddict
    • https://abp.io/docs/latest/solution-templates/layered-web-application/deployment/openiddict-deployment
    • https://abp.io/community/articles/0znavo8r

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Hi,

    The error UNABLE_TO_VERIFY_LEAF_SIGNATURE is a Node.js SSL/TLS certificate chain verification error. This is not related to ABP or OpenIddict authentication — it means Node.js cannot verify the SSL certificate of your backend server during SSR requests.

    To help confirm the root cause, could you provide some details:

    1. Is your ABP backend running on HTTPS? If so, are you using a self-signed certificate or a certificate from a trusted CA?
    2. Are you running this in a development environment or production?
    3. Could you share the backend URL (or just the domain/host) so we can check the certificate chain?
    4. Does setting the environment variable NODE_TLS_REJECT_UNAUTHORIZED=0 before starting your SSR server make the error go away? (This is only for testing, not a production solution.)

    Thanks

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.