From 1e0f713e450388b3ce1b9d60d78d2d8b4650fee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 20 Sep 2022 14:30:58 +0300 Subject: [PATCH] Don't set HttpClientHandler.UseCookies in browser environment. --- .../ServiceCollectionHttpClientProxyExtensions.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs b/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs index 2f7942fabe..3f71924f9d 100644 --- a/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs +++ b/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Net.Http; using System.Reflection; +using System.Runtime.InteropServices; using Castle.DynamicProxy; using JetBrains.Annotations; using Volo.Abp; @@ -213,9 +214,14 @@ public static class ServiceCollectionHttpClientProxyExtensions { clientBuildAction(remoteServiceConfigurationName, provider, client); } - }).ConfigurePrimaryHttpMessageHandler((provider) => + }).ConfigurePrimaryHttpMessageHandler(provider => { - var handler = new HttpClientHandler { UseCookies = false }; + var handler = new HttpClientHandler(); + + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER"))) + { + handler.UseCookies = false; + } foreach (var handlerAction in preOptions.ProxyClientHandlerActions) { @@ -243,6 +249,7 @@ public static class ServiceCollectionHttpClientProxyExtensions /// Currently the type is checked statically against some fixed conditions. /// /// Type to check + /// Option to filter application service types /// True, if the type is suitable for proxying. Otherwise false. private static bool IsSuitableForClientProxying( Type type,