Skip to content

Use USE_LOCAL_ASSETS env var to determine path for assets#16256

Open
jonathonherbert wants to merge 6 commits into
mainfrom
jsh/use-env-to-determine-public-path
Open

Use USE_LOCAL_ASSETS env var to determine path for assets#16256
jonathonherbert wants to merge 6 commits into
mainfrom
jsh/use-env-to-determine-public-path

Conversation

@jonathonherbert

@jonathonherbert jonathonherbert commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What does this change?

Amend decidePublicPath to use the environment variable USE_LOCAL_ASSETS to determine the path for assets, rather than a combination of the NODE_ENV variable, and the hostname.

Why?

The hostname for using live harnesses to work on content atoms locally (docs) is always localhost. At the moment, decidePublicPath sees that hostname, and makes asset paths relative as a result — but because DCR isn't running locally, those paths don't resolve to assets. The hope is that this change accommodates both the workflows that require local assets (make dev, make prod-local, CI), and the workflows that require hosted assets (code, production, live harnesses).

Here's a table that maps out the old way, the new way, and the result, against all the workflows we know of (I've spoken to @arelra and @Jakeii). If other workflows exist, this PR may impact them, too — so please let me know if there's a row missing.

NODE_ENV (old) hostname (old) USE_LOCAL_ASSETS (new) Assets path
local development localhost true /assets/
prod-local production localhost true /assets/
ci production localhost true /assets/
code production code.dev-theguardian.com unset ${frontendAssetsFullURL}assets/
prod production theguardian.com unset ${frontendAssetsFullURL}assets/

How to test

  • CI passes
  • Running DCR locally (make dev) with frontend gives local asset paths
  • Running DCR locally (make prod-local) with frontend gives local asset paths
  • Running DCR in CODE works as expected
  • Running live harnesses with Preview works as expected

Screenshots

N/A

@github-actions

Copy link
Copy Markdown

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@jonathonherbert jonathonherbert added the maintenance Departmental tracking: maintenance work, not a fix or a feature label Jun 24, 2026
@jonathonherbert jonathonherbert added this to the Interactives milestone Jun 24, 2026
@jonathonherbert jonathonherbert requested a review from a team as a code owner June 24, 2026 11:53
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

@jonathonherbert jonathonherbert force-pushed the jsh/use-env-to-determine-public-path branch from 3360067 to 0c9e5ce Compare June 25, 2026 10:26
@jonathonherbert jonathonherbert added the run_chromatic Runs chromatic when label is applied label Jun 25, 2026
@github-actions github-actions Bot removed the run_chromatic Runs chromatic when label is applied label Jun 25, 2026
@jonathonherbert jonathonherbert changed the title Use CI and NODE_ENV env vars to determine path for assets Use USE_LOCAL_ASSETS env var to determine path for assets Jun 25, 2026
@jonathonherbert jonathonherbert force-pushed the jsh/use-env-to-determine-public-path branch from 106d749 to 0e07458 Compare June 25, 2026 16:48
@jonathonherbert jonathonherbert added the run_chromatic Runs chromatic when label is applied label Jun 26, 2026
@github-actions github-actions Bot removed the run_chromatic Runs chromatic when label is applied label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Departmental tracking: maintenance work, not a fix or a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants