Skip to content

Fix missing images on PR preview deployments#61

Merged
brooke-hamilton merged 2 commits into
mainfrom
brooke-hamilton-bookish-enigma
Jun 19, 2026
Merged

Fix missing images on PR preview deployments#61
brooke-hamilton merged 2 commits into
mainfrom
brooke-hamilton-bookish-enigma

Conversation

@brooke-hamilton

Copy link
Copy Markdown
Member

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:

STAGING_URL="https://${SWA_BASE}-${{github.event.number}}.3.azurestaticapps.net/"
hugo ${STAGING_URL+-b "$STAGING_URL"}

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 with ERR_BLOCKED_BY_ORB, so images render blank.

Fix

For pull_request builds, stop guessing the preview hostname and build with a root-relative baseURL so <base href="/"> resolves against whatever host actually serves the page:

- name: Build Hugo Site
  run: |
    if [ "${GITHUB_EVENT_NAME}" == 'pull_request' ]; then
      hugo -b "/"
    else
      hugo
    fi

The now-unused SWA_BASE env var was removed (it was only referenced by the old step).

Why production is unaffected

Production builds (push to main) take the else branch and use the repo's configured baseURL (https://radapp.io/), which already matches its serving domain. Only the preview branch behavior changes.

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>
@brooke-hamilton brooke-hamilton requested a review from a team as a code owner June 19, 2026 19:15
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_BASE environment variable from the workflow.
  • For pull_request builds, run hugo -b "/" instead of constructing a preview hostname.
  • Keep production (push to main) builds unchanged by continuing to run hugo with the configured repository baseURL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@brooke-hamilton brooke-hamilton merged commit abe884b into main Jun 19, 2026
6 checks passed
@brooke-hamilton brooke-hamilton deleted the brooke-hamilton-bookish-enigma branch June 19, 2026 19:22
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.

3 participants