1

I am attempting to create a Blazor plugin (related question) that can be embedded in any random domain (call it randomClientDomain.com).

Everything seems to load but blazor.webassembly.js throws "The URI 'https://SomeRandomDomain.com' is not contained by the base URI 'https://politachat.com/plugin'"

For this specific error the index.html on randomClientDomain.com includes:

<head>
    <base href="/" />
</head>
<body>
    <div id="PolitaChatPlugin" class="col-11"></div>
    <script src="https://politachat.com/plugin/_framework/blazor.webassembly.js"></script> 
         // some code omitted for brevity
</body>

and my Program.cs in the Blazor app is:

builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri("/") });

I've tried just about every combination for <base> and HttpClient (edit: including ensuring the trailing forward slash is present in BaseAddress, where needed). I think the error is correct, but non-applicable in my case. Is it possible to fix it, or at least have it ignored?

Jason
  • 396
  • 1
  • 3
  • 17
  • Does this answer your question? [Why is HttpClient BaseAddress not working?](https://stackoverflow.com/questions/23438416/why-is-httpclient-baseaddress-not-working) – Yogi Apr 09 '22 at 22:10
  • @Yogi No, that's unrelated. I've edited the question to reflect that. Appreciate the help though. – Jason Apr 10 '22 at 12:42
  • 1
    In .NET 6 there are [Blazor Custom Elements](https://github.com/aspnet/AspLabs/tree/main/src/BlazorCustomElements) which mght help, but I've not found any examples of making a Blazor component work across domains. – Yogi Apr 10 '22 at 13:46

0 Answers0