Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Angular prerendering with Https #851

Closed

Description

@nicolaslawdune

Hi,

I try to retrieve some data during pre-rendering process and I face to this error :
Microsoft.AspNetCore.NodeServices: Information: Response { _body: { Error: unable to verify the first certificate at TLSSocket.<anonymous> (_tls_wrap.js:1084:38) at ZoneDelegate.invokeTask (C:\project\wwwroot\dist\server.js:66611:31) at Object.onInvokeTask (C:\project\\wwwroot\dist\server.js:43865:37) at ZoneDelegate.invokeTask (C:\project\wwwroot\dist\server.js:66610:36) at Zone.runTask (C:\project\wwwroot\dist\server.js:66378:47) at TLSSocket.ZoneTask.invoke (C:\project\wwwroot\dist\server.js:66673:38) at emitNone (events.js:86:13) at TLSSocket.emit (events.js:188:7) at TLSSocket._finishInit (_tls_wrap.js:606:8) at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:436:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }, status: 200, ok: true, statusText: 'Ok', headers: Headers { _headers: Map {}, _normalizedNames: Map {} }, type: 3, url: null }

Context

  • Development environnement with Https

  • WebAPI

  • ASP.NET Core with Microsoft.AspNetCore.SpaServices for pre-rendering

  • Angular 2

  • This error occures just after executing the http request (GET, POST etc...).

  • Pre-rendering of pages works.

Configuration

`export default createServerRenderer(params => {

const doc = '<app></app>';
return new Promise<RenderResult>((resolve, reject) => {
    const requestZone = Zone.current.fork({
        name: 'Angular-Universal Request',
        properties: {
            baseUrl: '/',
            requestUrl: params.url,
            originUrl: params.origin,
            cookies: params.data.cookies,
            ngModule: AppModule,
            preboot: false,
            document: doc
        },
        onHandleError: (parentZone, currentZone, targetZone, error) => {
            // If any error occurs while rendering the module, reject the whole operation
            reject(error);
            return true;
        }
    });

    return requestZone.run<Promise<string>>(() => platform.serializeModule(AppModule)).then(html => {
        resolve({ html: html });
    }, reject);
});

});`

WebAPI Url is actually "hard coded" (specified with its full url path https://localhost:433/api/user).

Thank you for your help.

Activity

  1. nicolaslawdune commented on Apr 9, 2017

    @nicolaslawdune
    Author

    If I deactivate HTTPS, Http request works.

  2. SteveSandersonMS commented on Apr 11, 2017

    @SteveSandersonMS
    Member

    I think you're running into this issue: angular/universal-starter#172

    This suggests you're running an older version of Zone.js. If you update to a newer version of that dependency, this problem should be fixed.

    Note that the current templates on this repo use Zone.js version ^0.7.6. I've just checked and confirmed there's no error with fetching HTTPS resources using that version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions