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
@nicolaslawdune

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.

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