Fix missing images on PR preview deployments#61
Merged
Conversation
PR-preview builds baked a guessed preview hostname into Hugo's baseURL, which the theme emits as <base href>. Azure serves previews from a region-qualified host, so the base-href host differed from the serving host and all relative asset URLs resolved cross-origin, getting blocked by Chrome (ERR_BLOCKED_BY_ORB) and rendering images blank. Build pull_request previews with a root-relative baseURL (-b /) so the emitted <base href="/"> resolves against whatever host serves the page. Production builds (push to main) are untouched and keep the repo-configured baseURL. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR fixes broken image rendering in Azure Static Web Apps PR-preview deployments by avoiding a guessed preview hostname in Hugo’s baseURL. For pull_request events, the workflow now builds the site with a root-relative base URL so the theme’s <base href="{{ site.BaseURL }}"> resolves assets against the actual preview host being served.
Changes:
- Remove the unused
SWA_BASEenvironment variable from the workflow. - For
pull_requestbuilds, runhugo -b "/"instead of constructing a preview hostname. - Keep production (
pushtomain) builds unchanged by continuing to runhugowith the configured repositorybaseURL.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
DariuszPorowski
approved these changes
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Azure Static Web Apps PR-preview deployments render all images blank (0×0). The CI workflow baked a guessed preview hostname into Hugo's
baseURL:This produced e.g.
https://brave-pond-00b49761e-59.3.azurestaticapps.net/, which the theme emits as<base href="{{ site.BaseURL }}">(themes/bigspring-light/layouts/partials/head.html).But Azure actually serves the preview from a region-qualified host like
https://brave-pond-00b49761e-59.westus2.3.azurestaticapps.net/. Because the<base href>host differs from the host actually serving the page, every relative asset URL (e.g./images/...) resolves cross-origin. Chrome blocks those requests withERR_BLOCKED_BY_ORB, so images render blank.Fix
For
pull_requestbuilds, stop guessing the preview hostname and build with a root-relative baseURL so<base href="/">resolves against whatever host actually serves the page:The now-unused
SWA_BASEenv var was removed (it was only referenced by the old step).Why production is unaffected
Production builds (push to
main) take theelsebranch and use the repo's configuredbaseURL(https://radapp.io/), which already matches its serving domain. Only the preview branch behavior changes.