Repository navigation
Description
Prerequisites
- I have read the Contributing Guidelines.
- I have not leaked any internal/restricted information like screenshots, videos, code snippets, links etc.
Affected component
Summary
After updating @siemens/live-preview from 51.6.0 to 51.8.0, the example preview no longer renders when using the Angular dev server (ng serve). The navigation panel works, but the example area in the middle stays empty. Production builds aren't affected.
Suggested fix
Resolve the application URL from the host document, for example new URL('.', document.baseURI), or make it configurable through SiLivePreviewConfig. Use import.meta.url only where module-relative resolution is really needed, such as embeddable elements loaded cross-origin.
Version
@siemens/live-preview51.8.0 (works with 51.6.0)- Angular 22.2.3,
ng serve(Vite 8 dev server, dependency pre-bundling enabled by default) - pnpm
Steps to reproduce
- Set up live preview as documented (
SimplLivePreviewModule.forRoot({ componentLoader, examplesBaseUrl: 'app/examples/', ... })withlivePreviewRoutes). - Run
ng serveand open an example.
Code reproduction example
...
What is the current bug behavior
The iframe src points into Vite's dependency cache instead of the application root:
http://localhost:4200/@fs/<project>/.angular/cache/22.2.3/<app>/vite/deps/#/iframe?parentOrigin=...
Inside the iframe, main.js, polyfills.js and styles.css return 404, so the example never boots.
LivePreviewUrlService works out the application URL from the location of its own module:
// Keep resolution at runtime to avoid Vite rewriting '.' as a filesystem asset.
applicationUrl = new URL('.', new URL(import.meta.url));
iframeUrl = this.routeUrl('iframe', ...);
examplesBaseUrl = new URL(this.config.examplesBaseUrl, this.applicationUrl).href;With Vite dependency pre-bundling, import.meta.url is .../.angular/cache/.../vite/deps/@siemens_live-preview.js, so applicationUrl, and with it iframeUrl and examplesBaseUrl, resolve to the cache folder.
In 51.6.0 the iframe used a relative src="#/iframe", which always resolved against the host page. This probably came in with "live-preview: expose embeddable preview elements" (81e7728) in 51.7.0.
There's no config option to override the application URL, and LivePreviewUrlService isn't exported, so consumers can't fix it through DI.
What is the expected correct behavior
When running the app with the Angular dev server (ng serve), the live preview should render the selected example in the preview area, as it did in 51.6.0 and as it does in production builds.
Specifically:
- The preview iframe should load the application root, e.g.
http://localhost:4200/#/iframe?parentOrigin=..., not a path inside Vite's dependency cache (.../.angular/cache/.../vite/deps/#/iframe?...). main.js,polyfills.jsandstyles.cssshould load inside the iframe without 404 errors, and the example component should boot and be displayed.examplesBaseUrlshould resolve against the application root, so example sources (template/TypeScript tabs) load correctly.- This should work with Vite's default dependency pre-bundling enabled, without needing
prebundle.excludefor@siemens/live-previewinangular.json.
Activity
reto-siemens commentedon Nov 27, 2026
We hit the same root cause in a production build, not only with
ng serve: when the app is served via GitLab job-artifact browsing (…/-/jobs/<id>/artifacts/public/index.html),new URL('.', import.meta.url)resolves to…/artifacts/public/, so the iframe requests…/artifacts/public/#/iframe?…. The artifact browser doesn't serveindex.htmlfor directory URLs, so that request returns 404. Note that the suggestednew URL('.', document.baseURI)would still fail here; route URLs (iframe,viewer/...) should keep the document file name, e.g. build them fromdocument.location.hrefwith only the hash replaced, as the relativesrc="#/iframe"in 51.6.0 effectively did.panch1739 commentedon Dec 1, 2026
@spike-rabbit could you maybe take a look here? :)
spike-rabbit commentedon Dec 1, 2026
@Chreggii / @reto-siemens can you please verify that #3357 would solve your issue. For me everything looks good.