Ajax Calls Return 401 When .NET Core Site Is Deployed

It seems to me that your problem could be because of different behavior of cookies in http vs https scenarios!

Secured cookies that set in https mode can't be retrieved when posted back to http.

See this for more info.

I also saw this part in your Startup which increases the chance of my guess:

if (env.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}
else
{
    app.UseExceptionHandler("/Error");
    app.UseHsts();
}

In your development environment everything works well on http. But in deployment environment https comes in and if some requests go to http and some go to https, some cookies don't return and you can face this issue.