You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Serving Angular from Electron breaks since @angular/platform-browser 17.0.5 #53546
Which @angular/* package(s) are the source of the bug?
platform-browser, router
Is this a regression?
Yes
Description
Electron serves applications with the file:// protocol and therefore requires to set <base href=".">.
Unfortunately the commit that was supposed to just be a refactor breaks that use case. 162d940
As with a file system base path, these functions do not return the same value at all, which breaks the router.
Old relativePath implementation: relativePath(".") --> '/C:/.../build/angular-builds/browser/en/'
New relativePath implementation: relativePath(".") --> '/
I'd submit a PR to revert the changes, but according to @crisbeto's comment in that PR, this change was required for something in Material, so I assume something else needs to be done.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
As a consequence, you get a runtime error with nothing loading at all:
main-RYNXSWOY.js:162 ERROR Error: NG04002
at fce.noMatchError (main-RYNXSWOY.js:1013:87185)
at main-RYNXSWOY.js:1013:87870
at main-RYNXSWOY.js:158:26148
at See._error (main-RYNXSWOY.js:158:5647)
at See.error (main-RYNXSWOY.js:158:2651)
at See._error (main-RYNXSWOY.js:158:2897)
at See.error (main-RYNXSWOY.js:158:2651)
at See._error (main-RYNXSWOY.js:158:2897)
at See.error (main-RYNXSWOY.js:158:2651)
at See._error (main-RYNXSWOY.js:158:2897)
Please provide the environment you discovered this bug in (run ng version)
Are you sure that the base element is pointing to "."? I just tried both the new and old implementations of relativePath('.') and they return the same value. I'm wondering if Electron isn't patching the URL class somehow.
Thanks for the repro. I need to look into it more, but I think that we can resolve it by passing in document.baseURI instead of the http://a.
I was just about to add what I think is the same issue. We are using './' as the base-href in our builds, and if the app is served from somewhere below root, we get the entire path from root in the activated route, and the router doesn't work with parameters. I have repos that illustrate the problem (which I can provide somehow if it would help), but here is what they produce:
@scottg521 Can you try to update to Angular 17.0.7? The issue I mentioned has been addressed and I assume so is yours.
Hey did u fixed it??? I got this error while running electron on my Angular 17 :
chunk-DVUE4UAR.js:7 ERROR Error: NG04002
at _s.noMatchError (chunk-TM6YNNTS.js:2:100971)
at chunk-TM6YNNTS.js:2:101646
at chunk-DVUE4UAR.js:3:13351
at Jo._error (chunk-DVUE4UAR.js:3:12151)
at Jo.error (chunk-DVUE4UAR.js:3:2591)
at Jo._error (chunk-DVUE4UAR.js:3:2831)
at Jo.error (chunk-DVUE4UAR.js:3:2591)
at Jo._error (chunk-DVUE4UAR.js:3:2831)
at Jo.error (chunk-DVUE4UAR.js:3:2591)
at Jo._error (chunk-DVUE4UAR.js:3:2831)
Activity
crisbeto commentedon Dec 13, 2023
Are you sure that the
baseelement is pointing to"."? I just tried both the new and old implementations ofrelativePath('.')and they return the same value. I'm wondering if Electron isn't patching theURLclass somehow.wartab commentedon Dec 13, 2023
Yes, it is. Try the following (make sure you serve it as a file, not from an HTTP server):
You'll see
crisbeto commentedon Dec 13, 2023
Thanks for the repro. I need to look into it more, but I think that we can resolve it by passing in
document.baseURIinstead of thehttp://a.wartab commentedon Dec 13, 2023
I came to a similar conclusion. I'm using location.href however, not sure if it makes a difference.
scottg521 commentedon Dec 13, 2023
I was just about to add what I think is the same issue. We are using './' as the base-href in our builds, and if the app is served from somewhere below root, we get the entire path from root in the activated route, and the router doesn't work with parameters. I have repos that illustrate the problem (which I can provide somehow if it would help), but here is what they produce:
Here are the routes:
fix(platform-browser): Get correct base path when using "." as base h…
wartab commentedon Dec 14, 2023
@scottg521 Can you try to update to Angular 17.0.7? The issue I mentioned has been addressed and I assume so is yours.
scottg521 commentedon Dec 15, 2023
Yes, confirming that 17.0.7 fixes our issue. Thanks for the quick response.
biondiBagasta commentedon Dec 28, 2023
Hey did u fixed it??? I got this error while running electron on my Angular 17 :
fix(platform-browser): Get correct base path when using "." as base h…
fix(platform-browser): Get correct base path when using "." as base h…
fix(platform-browser): Get correct base path when using "." as base h…
angular-automatic-lock-bot commentedon Jan 28, 2024
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.