Skip to content

Commit

Permalink
Attempts to fix display url
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldgray committed May 22, 2024
1 parent 74fece6 commit d014883
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System.Text;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Preservation.API.Models;

namespace Preservation.API.Controllers;

[Route("[controller]/{*path}")]
[ApiController]
public class RepositoryController(IPreservation preservation, ModelConverter modelConverter) : Controller
public class RepositoryController(
IPreservation preservation,
ModelConverter modelConverter,
ILogger<RepositoryController> logger) : Controller
{
/// <summary>
/// Browse underlying repository for Container, DigitalObject or Binary.
Expand Down Expand Up @@ -56,7 +58,10 @@ public Uri GetCorrectDisplayUrl()
{
// HACK avoid `https://uol.digirati:80` when behind ELB
var displayUrl = HttpContext.Request.GetDisplayUrl();
logger.LogInformation("DisplayUrl {UrlAsString}", displayUrl);
var uri = new Uri(displayUrl);

logger.LogInformation("Url Port and Scheme: {Port} and {Scheme}", uri.Scheme, uri.Port);
if (uri is { Scheme: "https", Port: -1 or 80 })
{
var uriBuilder = new UriBuilder(uri) { Port = 443 };
Expand Down

0 comments on commit d014883

Please sign in to comment.