Skip to content

Angular server side rendering doesn't work correctly with asp.net core project configured for https #691

@taras-pyvovarov

Description

@taras-pyvovarov

I'm rather new to Angular and trying to use this template to start a project, remove everything I don't need, configure what I need.

I found out that if to make additional setup for asp.net core project to use only https, SSR still works for rendering menus, buttons, but it doesn't perform api calls for content on server prerendering stage anymore, it happens in browser instead. As a result, if I disable javascript in browser and go to Rest API Demo, I still see the page looking quite normally, but with Loading... instead of list of users.

Is there some kind of catch? Am I missing something? Not being able to make api calls on server prerendering pretty much destroys SEO and the whole point of SSR.

To reproduce this, it's enough to open Startup.cs and add the following to the ConfigureServices() method:

services.AddHttpsRedirection(options =>
{
    options.RedirectStatusCode = StatusCodes.Status301MovedPermanently;
});
services.AddMvc((Microsoft.AspNetCore.Mvc.MvcOptions x) =>
{
    x.Filters.Add(new Microsoft.AspNetCore.Mvc.RequireHttpsAttribute());
});

Then add this to Configure() method:
app.UseHttpsRedirection();

Then just update Properties\launchSettings,json to use https, for example: https://localhost:44345/

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