Skip to content

Commit

Permalink
Merge branch 'release/6.41.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
vc-ci committed Mar 26, 2024
2 parents 0380cf9 + ab97932 commit c58f4db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Authors>VirtoCommerce</Authors>
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>6.40.0</VersionPrefix>
<VersionPrefix>6.41.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' != '' AND '$(BuildNumber)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
Expand Down
26 changes: 18 additions & 8 deletions VirtoCommerce.Storefront/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text.Encodings.Web;
using System.Text.Unicode;
using System.Threading.Tasks;
using FluentValidation.AspNetCore;
using GraphQL.Client.Abstractions;
using GraphQL.Client.Http;
Expand Down Expand Up @@ -340,6 +342,8 @@ public void ConfigureServices(IServiceCollection services)

services.AddProxy(builder => builder.AddHttpMessageHandler(sp => sp.GetService<AuthenticationHandlerFactory>().CreateAuthHandler()));

services.Configure<ProxyOptions>(options => options.WebSocketKeepAliveInterval = TimeSpan.FromSeconds(50));

services.AddSingleton<IGraphQLClient>(s =>
{
var platformEndpointOptions = s.GetRequiredService<IOptions<PlatformEndpointOptions>>().Value;
Expand Down Expand Up @@ -427,16 +431,22 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
});

var platformEndpointOptions = app.ApplicationServices.GetRequiredService<IOptions<PlatformEndpointOptions>>().Value;
// Forwards the request only when the host is set to the specified value
app.UseWhen(
context => context.Request.Path.Value.EndsWith("xapi/graphql"),
appInner => appInner.RunProxy(context =>

var httpsPlatformGraphqlEndpoint = new Uri(platformEndpointOptions.Url, "graphql");
var wssPlatformGraphqlEndpoint = new UriBuilder(httpsPlatformGraphqlEndpoint)
{
Scheme = httpsPlatformGraphqlEndpoint.Scheme == Uri.UriSchemeHttps ? Uri.UriSchemeWss : Uri.UriSchemeWs
}.Uri;

app.UseWebSockets();
app.Map("/xapi/graphql",
appInner =>
{
context.Request.Path = PathString.Empty;
return context.ForwardTo(new Uri(platformEndpointOptions.Url, "graphql"))
appInner.UseWebSocketProxy(_ => wssPlatformGraphqlEndpoint, options => options.AddXForwardedHeaders());
appInner.RunProxy(context => context.ForwardTo(httpsPlatformGraphqlEndpoint)
.AddXForwardedHeaders()
.Send();
}));
.Send());
});

app.UseWhen(
context => context.Request.Path.Value.EndsWith("/token"),
Expand Down

0 comments on commit c58f4db

Please sign in to comment.