mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Fix SignalR paths if RootPath is used
This commit is contained in:
@@ -109,11 +109,13 @@ namespace BTCPayServer.Controllers
|
||||
|
||||
return NotFound("A Target Currency must be set for this app in order to be loadable.");
|
||||
}
|
||||
if (settings.Enabled) return View(await _AppService.GetAppInfo(appId));
|
||||
var appInfo = (ViewCrowdfundViewModel)(await _AppService.GetAppInfo(appId));
|
||||
appInfo.HubPath = AppHub.GetHubPath(this.Request);
|
||||
if (settings.Enabled) return View(appInfo);
|
||||
if(!isAdmin)
|
||||
return NotFound();
|
||||
|
||||
return View(await _AppService.GetAppInfo(appId));
|
||||
return View(appInfo);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@@ -137,7 +139,7 @@ namespace BTCPayServer.Controllers
|
||||
}
|
||||
|
||||
var info = (ViewCrowdfundViewModel)await _AppService.GetAppInfo(appId);
|
||||
|
||||
info.HubPath = AppHub.GetHubPath(this.Request);
|
||||
if (!isAdmin &&
|
||||
((settings.StartDate.HasValue && DateTime.Now < settings.StartDate) ||
|
||||
(settings.EndDate.HasValue && DateTime.Now > settings.EndDate) ||
|
||||
|
||||
@@ -215,6 +215,7 @@ namespace BTCPayServer.Controllers
|
||||
public async Task<IActionResult> ViewPaymentRequest(string id)
|
||||
{
|
||||
var result = await _PaymentRequestService.GetPaymentRequest(id, GetUserId());
|
||||
result.HubPath = PaymentRequestHub.GetHubPath(this.Request);
|
||||
if (result == null)
|
||||
{
|
||||
return NotFound();
|
||||
|
||||
@@ -174,8 +174,8 @@ namespace BTCPayServer.Hosting
|
||||
app.UseAuthentication();
|
||||
app.UseSignalR(route =>
|
||||
{
|
||||
route.MapHub<AppHub>("/apps/hub");
|
||||
route.MapHub<PaymentRequestHub>("/payment-requests/hub");
|
||||
AppHub.Register(route);
|
||||
PaymentRequestHub.Register(route);
|
||||
});
|
||||
app.UseWebSockets();
|
||||
app.UseStatusCodePages();
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace BTCPayServer.Models.AppViewModels
|
||||
{
|
||||
public class ViewCrowdfundViewModel
|
||||
{
|
||||
public string HubPath { get; set; }
|
||||
public string StatusMessage{ get; set; }
|
||||
public string StoreId { get; set; }
|
||||
public string AppId { get; set; }
|
||||
|
||||
@@ -134,6 +134,7 @@ namespace BTCPayServer.Models.PaymentRequestViewModels
|
||||
public string AmountCollectedFormatted { get; set; }
|
||||
public string AmountFormatted { get; set; }
|
||||
public bool AnyPendingInvoice { get; set; }
|
||||
public string HubPath { get; set; }
|
||||
|
||||
public class PaymentRequestInvoice
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ using BTCPayServer.Services.PaymentRequests;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using BTCPayServer.Services.Apps;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace BTCPayServer.PaymentRequest
|
||||
{
|
||||
@@ -59,6 +60,15 @@ namespace BTCPayServer.PaymentRequest
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetHubPath(HttpRequest request)
|
||||
{
|
||||
return request.GetRelativePathOrAbsolute("/payment-requests/hub");
|
||||
}
|
||||
public static void Register(HubRouteBuilder route)
|
||||
{
|
||||
route.MapHub<PaymentRequestHub>("/payment-requests/hub");
|
||||
}
|
||||
}
|
||||
|
||||
public class PaymentRequestStreamer : EventHostedServiceBase
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
"BTCPAY_BTCEXTERNALCHARGE": "server=https://127.0.0.1:53280/mycharge/btc/;cookiefilepath=fake",
|
||||
"BTCPAY_BTCEXPLORERURL": "http://127.0.0.1:32838/",
|
||||
"BTCPAY_DISABLE-REGISTRATION": "false",
|
||||
"BTCPAY_ROOTPATH": "/test",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"BTCPAY_CHAINS": "btc,ltc",
|
||||
"BTCPAY_POSTGRES": "User ID=postgres;Host=127.0.0.1;Port=39372;Database=btcpayserver",
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Controllers;
|
||||
using BTCPayServer.Models.AppViewModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -62,5 +63,13 @@ namespace BTCPayServer.Services.Apps
|
||||
|
||||
}
|
||||
|
||||
public static string GetHubPath(HttpRequest request)
|
||||
{
|
||||
return request.GetRelativePathOrAbsolute("/apps/hub");
|
||||
}
|
||||
public static void Register(HubRouteBuilder route)
|
||||
{
|
||||
route.MapHub<AppHub>("/apps/hub");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
var hubListener = function(){
|
||||
|
||||
var connection = new signalR.HubConnectionBuilder().withUrl("/apps/hub").build();
|
||||
var connection = new signalR.HubConnectionBuilder().withUrl(srvModel.hubPath).build();
|
||||
|
||||
connection.onclose(function(){
|
||||
eventAggregator.$emit("connection-lost");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var hubListener = function () {
|
||||
|
||||
var connection = new signalR.HubConnectionBuilder().withUrl("/payment-requests/hub").build();
|
||||
var connection = new signalR.HubConnectionBuilder().withUrl(srvModel.hubPath).build();
|
||||
|
||||
connection.onclose(function () {
|
||||
eventAggregator.$emit("connection-lost");
|
||||
|
||||
Reference in New Issue
Block a user