Skip to content

fix(live-preview): resolve standalone preview URLs from document location - #3357

Draft
spike-rabbit wants to merge 1 commit into
mainfrom
fix/live-preview-application-url
Draft

spike-rabbit wants to merge 1 commit into
mainfrom
fix/live-preview-application-url

Conversation

@spike-rabbit

@spike-rabbit spike-rabbit commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Resolve live-preview iframe, viewer, and example source URLs from
document.location.href by default instead of import.meta.url.

Previously, LivePreviewUrlService always derived the application base URL
from new URL('.', new URL(import.meta.url)). That broke standalone
consumers in two cases:

  • During ng serve, Vite pre-bundles @siemens/live-preview into its cache
    directory, causing preview iframes and source requests to point into
    .angular/cache/.../vite/deps/.
  • On static hosts that do not serve index.html for directory URLs (such as
    GitLab job-artifact browsing), stripping index.html caused iframe route
    requests to return 404.

Provide the default URL via an internal SI_LIVE_PREVIEW_APPLICATION_URL
token and override it in defineLivePreviewElements for embedded
<si-docs-component> elements. Add an optional applicationUrl option to
defineLivePreviewElements so embedded apps can pass their entry module URL
explicitly when serving via Vite or hosting without directory-index
resolution.

Fixes #3303


Documentation.
Examples.
Dashboards Demo.
Playwright report.

Coverage Reports:

Code Coverage

…tion

Resolve live-preview iframe, viewer, and example source URLs from
`document.location.href` by default instead of `import.meta.url`.

Previously, `LivePreviewUrlService` always derived the application base URL
from `new URL('.', new URL(import.meta.url))`. That broke standalone
consumers in two cases:
- During `ng serve`, Vite pre-bundles `@siemens/live-preview` into its cache
  directory, causing preview iframes and source requests to point into
  `.angular/cache/.../vite/deps/`.
- On static hosts that do not serve `index.html` for directory URLs (such as
  GitLab job-artifact browsing), stripping `index.html` caused iframe route
  requests to return 404.

Provide the default URL via an internal `SI_LIVE_PREVIEW_APPLICATION_URL`
token and override it in `defineLivePreviewElements` for embedded
`<si-docs-component>` elements. Add an optional `applicationUrl` option to
`defineLivePreviewElements` so embedded apps can pass their entry module URL
explicitly when serving via Vite or hosting without directory-index
resolution.

Fixes #3303

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

live-preview: preview iframe stays empty with ng serve since 51.7.0/51.8.0 (import.meta.url resolves into Vite's pre-bundle cache)

1 participant