Authentication cookie disappears in react SPA after some time

Finally, I figured out how to tackle this.

It had to do with the configuration of IdentityServer. The missing part was the method AddAspNetIdentity<LoginInputModel>().

Before:

var certificate = LoadSigningCertificate();
var identityServerBuilder = services.AddIdentityServer(options =>
                                                       {
                                                           options.Events.RaiseErrorEvents = true;
                                                           options.Events.RaiseInformationEvents = true;
                                                           options.Events.RaiseFailureEvents = true;
                                                           options.Events.RaiseSuccessEvents = true;
                                                       })
                                    .AddSigningCredential(certificate)
                                    .AddProfileService<ProfileService>()
                                    .AddInMemoryIdentityResources(Config.Ids)
                                    .AddInMemoryApiResources(Config.Apis)
                                    .AddInMemoryClients(new ClientConfigLoader().LoadClients(Configuration));

Now:

var certificate = LoadSigningCertificate();
var identityServerBuilder = services.AddIdentityServer(options =>
                                                       {
                                                           options.Events.RaiseErrorEvents = true;
                                                           options.Events.RaiseInformationEvents = true;
                                                           options.Events.RaiseFailureEvents = true;
                                                           options.Events.RaiseSuccessEvents = true;
                                                       })
                                    .AddSigningCredential(certificate)
                                    .AddAspNetIdentity<LoginInputModel>()
                                    .AddProfileService<ProfileService>()
                                    .AddInMemoryIdentityResources(Config.Ids)
                                    .AddInMemoryApiResources(Config.Apis)
                                    .AddInMemoryClients(new ClientConfigLoader().LoadClients(Configuration));

With that additional configuration line, Identity Server is handling the cookie correctly.