1

I'm encountering an SSL certificate issue with Angular SSR (Server-Side Rendering) when trying to access my .NET backend. The interesting part is that everything works perfectly fine on client-side rendering.

Environment

  • Angular 18 (also tested with Angular 19 RC)
  • .NET backend running on https://localhost:7205
  • Certificate is added to root certificate store and shows as trusted in browser

What's Working

  • Client-side requests work perfectly fine
  • Certificate is recognized as trusted in browser
  • Backend endpoints are accessible directly through browser

What's Not Working

During SSR, I get the following error when trying to make HTTP requests:

HTTP Error Intercepted: HttpErrorResponse {
      status: 0,
      statusText: 'Unknown Error',
      url: 'https://localhost:7205/api/Account/MyInfo',
      ok: false,
      message: 'Http failure response for https://localhost:7205/api/Account/MyInfo: 0 Unknown Error'
    }

I attempted to disable SSL verification on the server by adding this to server.ts: Beside that, the file is the default.

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

However, this didn't resolve the issue.

Any guidance or suggestions would be greatly appreciated. Thank you!

3
  • setting env that way is not a working way. you should set it as env variable before starting the process Commented Nov 15, 2024 at 10:23
  • @Andrei This is my hole npm start script "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 ng serve -c development --ssl --ssl-cert ./ssl/server.crt --ssl-key ./ssl/server.key" Sadly still the same error Commented Nov 15, 2024 at 12:18
  • 1
    are you sure that the issue is ssl then? Commented Nov 15, 2024 at 13:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.