question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to change baseurl

See original GitHub issue

Description

Hey guys,

This is related to https://github.com/dotnet/aspnetcore/issues/35077 and I’m having a similar problem. and yes, this is a blocker for many use cases many people posted.

I’m suggesting an alternative solution: ability to change the base URL and let users choose to traffic fall through when base URL interception is not hit.

Public API Changes

Need to expose and give the ability to change outside of framework somehow:

https://github.com/dotnet/maui/blob/d0e903735c141cc5ce1f6a07a2265cfb0f8da3c3/src/BlazorWebView/src/Maui/BlazorWebView.cs#L11-L13

https://github.com/dotnet/maui/blob/ff3e934de281ef241f84f85fa6c2825b390d732e/src/BlazorWebView/src/SharedSource/WebView2WebViewManager.cs#L50-L60

on a side note: this won’t make requests substantially faster because there’s will be no DNS resolution as long as we intercept. and even if they do resolution will be cached so this will be premature optimization, don’t they?

Intended Use-Case

So similar to this issue (https://github.com/dotnet/aspnetcore/issues/35077)

example baseurl: contoso.com

  • case 1
  1. app start
  2. app shows the initial page
  3. app trying to send ajax POST to contoso.com/some-api (not working, we need a server or fall through to browser request instead of injection)
  4. app continues to run
  • case 2
  1. app start
  2. app shows the initial page
  3. user input, app trying to redirect to a dynamic page with the same domain which only available via the server
  4. server redirects the user back to the original page

This is important because users shouldn’t alter their entire architecture because MAUI is not supporting it.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Bohdandncommented, Feb 10, 2023

One more use case: Since 0.0.0.0 is not considered as secure context by some old web views you get limited access to browser api via JS. Cordova allows changing is via hostname property in config.xml.

Example: iOS 14.5

if app origin: app://0.0.0.0/
windows.isSecureContext == false
navigator.mediaDevices == null
if app origin: app://localhost/
windows.isSecureContext == true
navigator.mediaDevices - has value, media devices accessible

It works on iOS 16.3 but we need to be backward compatible, iOS 14.X is still 6-14% of iOS market. So I’d make it configurable and default to 0.0.0.0. https://bugs.webkit.org/show_bug.cgi?id=220184

You can use WebRTC native libraries to get media devices but it doesn’t work on iOS because of bindings issue + it’s not fully hybrid approach (we have blazor wasm app as well). So @christallire the only workaround so far is:

var handlerType = typeof(BlazorWebViewHandler);
var field = handlerType.GetField("AppOriginUri", BindingFlags.Static | BindingFlags.NonPublic) ?? throw new Exception("AppOriginUri field not found");
field.SetValue(null, new Uri("app://localhost/"));
0reactions
christallirecommented, Mar 27, 2023

@Bohdandn thanks for the workaround. I was about to try WebRTC too! it would save a ton of time.

One funny thing is that it renders clarity (from Microsoft) unusable too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I manually change the base URL | Confluence
Retrieve the base URL from the bandana table: ... You can copy out the entire value and update the baseUrl, then insert the...
Read more >
Change the base URL of a Power Pages site
Learn how to change the base URL of a website. ... Under Resources, select Power Pages sites. Select the site for which you...
Read more >
How can I change my Server Base URL?
Yes , you can change Server Base URL . You can see a section site configuration in the General Configuration tab where you...
Read more >
how to change baseURL in retrofit interface? - java
The simple answer is just to use two RetroFit objects, since each object can only have one base url and they are designed...
Read more >
Base URL Capability
Go to the System section of the Administration menu and select Capabilities. Search for an existing Base URL capability and select it if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found