Problem with base href
sven5 opened this issue · comments
Hi,
there is an issue when the base url is set in HTML head of the Blazor app:
<base href="/SomePath/" />
You have to change function blazorPolyFill
on line 3500 to append the location.pathname
by creating the document.baseURI
.
For IE11, it's ok to set document.baseURI = location.href
.
Regards
Sven
Hello @sven5 ,
I'm actually a little busy at the moment.
If you have the solution, would it be possible for you to make a PR ?
Thanks !
Guillaume
Hello Guillaume,
yes it's possible, no problem. It looks like I didn't find the right solution at the moment, I'm working on this.
Regards
Sven
Thanks ;-) !
Now I have it.
The following line in Boot.ts
needs to be changed to:
document.baseURI = location.protocol + "//" + location.hostname + port + location.pathname + "/";
Actually, with your fix, you must ensure that location.pathname does not have already a trailing slash ('/') before adding "/" at the end. You may try to trim or check that.
But actually, i'm wondering why you are trying to override this value.
I would agree that for IE11, current implemention is wrong and it must be updated to reflect the correct document.baseURI behavior.
But normally, blazor.polyfill check if document.baseURI is defined. So, only IE11 should normally execute the current code you see in Boot.ts. Other browser should have already document.baseURI set in memory from the beginning, even without the polyfill library.
Yes you're right. I only need it for IE11.
Maybe a Little late, but is this still an issue ? What was your fix ?
Sorry i was mainly on customer projects and on BlazorMobile theses last month !
Hi @Daddoon
For me, this is no longer an issue. I don't use a different base address any longer so everything works as expected.
Regards
Sven
Thanks for your feedback !
Still, your idea was geat, i will re-open this issue, and try to fix this inconsistent behavior.
Expecting to do it today or tomorrow
Hello Sven,
A new release is available here, with the fix you have suggested:
https://github.com/Daddoon/Blazor.Polyfill/releases/tag/3.0.0-preview8.19405.7
Also, as Blazor server-mode does not automatically load on IE11 at the moment, i have added a fix in the polyfill in order to transparently load Blazor on IE11 without any extra-code on your side.
You can safely remove Blazor.start(); if you have any reference in your own project.
As stated in releases note:
New release, tested and base on Blazor 3.0.0-preview8.19405.7:
- Blazor server-side now load automatically on IE11, by calling Blazor.start(); internally when available.
- The document.baseURI should return the expected value on IE11 if the baseURI launched from your app is not at a root URI. The baseURI is now based on window.location.pathname at startup.
- Updated core-js package to prevend dependencies critical security breach
Thanks !
Thanks for your update and new release.
I always appreciate your efforts on this project because we need to support IE11 for our apps.
Regards
Sven
Thanks @sven5 !
It's true that Internet Explorer 11 is still mandatory in a lot of business company that cannot migrate on modern browsers.
Regards,
Guillaume