diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index 6d5ecfa..bf8cf40 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -1,5 +1,6 @@ @page "/boards/{Id:int}/{CardId:int?}" @using System.Security.Cryptography +@using System.IO @inject NavigationManager _navigationManager @inject IDbContextFactory _dbContextFactory @inject ProtectedLocalStorage _protectedLocalStorage @@ -177,23 +178,28 @@ return; var httpContext = _httpContextAccessor.HttpContext; + var uri = new Uri("http://localhost:8080" + Constants.Hubs.UPDATE_HUB); + +#if DEBUG + uri = new Uri("https://localhost:7225" + Constants.Hubs.UPDATE_HUB); +#endif _hubConnection = new HubConnectionBuilder() - .WithUrl(_navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB), options => - { - if(httpContext?.Request.Cookies is not null) + .WithUrl(uri, options => { - foreach (var cookie in httpContext.Request.Cookies) + var cookieName = ".AspNetCore.Identity.Application"; + var cookieValue = httpContext?.Request?.Cookies[cookieName]; + + if (!string.IsNullOrEmpty(cookieValue)) { options.Cookies.Add(new System.Net.Cookie { - Name = cookie.Key, - Value = cookie.Value, - Domain = new Uri(_navigationManager.BaseUri).Host + Name = cookieName, + Value = cookieValue, + Domain = uri.Host }); } - } - }) + }) .WithAutomaticReconnect() .Build(); diff --git a/Ticky.Web/Program.cs b/Ticky.Web/Program.cs index 1247a2f..d1cd2f8 100644 --- a/Ticky.Web/Program.cs +++ b/Ticky.Web/Program.cs @@ -155,7 +155,11 @@ mailKitOptions is null builder.Services.AddControllers(); -// builder.WebHost.UseUrls("https://0.0.0.0:7225"); +#if !DEBUG +// NOTE: In production, the application is expected to run behind a reverse proxy (e.g., Nginx, Traefik) that terminates HTTPS. +// Binding to HTTP here is intentional and safe in that context. Do NOT expose this endpoint directly to the internet. +builder.WebHost.UseUrls("http://0.0.0.0:8080"); +#endif var app = builder.Build();