Conversation
Both hardcoded https://frontside.com/effection, so every copy advertised production no matter where it was served from: locally llms.txt sent agents away from the dev server they were reading it on, and a preview sent reviewers to production. Everything else on the site escapes this because staticalize rewrites self referencing absolute urls — but only inside HTML. text/plain and application/rss+xml are copied to disk untouched, so their urls have to be right when the response is generated. Add `useSiteUrl()`, which builds urls from `SITE_URL` when it is set and from the origin of the request otherwise, and use it for both. The workflow sets `SITE_URL` per deploy: production advertises the canonical url, a preview advertises its own alias, and a fork, whose url is not known until after the deploy, falls back to the netlify site. The dev task sets it to localhost so development exercises the same code path.
commit: |
Contributor
|
🚀 Deploy Preview Ready!
|
This was referenced Sep 26, 2026
Member
Author
|
Superseded by #1248. staticalize 0.3.0 landed with the two fixes this PR was working around — it honours the path component of It also fixes something this PR did not. Previews have been building with |
This branch was successfully deployed
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.
Motivation
llms.txtandfeed.xmlhardcodedhttps://frontside.com/effection, so every copy advertised production regardless of where it was served from. Locally that meantllms.txtpointed agents away from the dev server they were reading it on; in a PR preview it pointed reviewers at production.Everything else on the site escapes this because staticalize rewrites self-referencing absolute urls — but only inside HTML.
downloader.tstakes that branch onContent-Type?.includes("html")and streams everything else to disk untouched, sotext/plainandapplication/rss+xmlare copied verbatim and their urls have to be correct when the response is generated.Approach
useSiteUrl()inwww/plugins/current-request.ts. With noSITE_URLit returnsuseAbsoluteUrlFactory(), the existing origin-based helper; with one set it builds urls from that base, preserving its path.llms.txtandfeed.xmluse it in place of the hardcoded constant.www.yamlsetsSITE_URLper deploy:https://frontside.com/effection, the canonical url, byte-identical to what these files contain todayhttps://pr-<N>--effection.netlify.app, computed before the server starts, since alias deploys land on a predictable url; fork PRs deploy anonymously to a url nobody knows in advance, so they fall back to the netlify production url::warning::fires if the site name netlify reports back differs fromNETLIFY_SITE_NAME, so the prediction cannot silently driftenvironment.urlfor previews now points at the alias deploy, so the link in the checks panel shares an origin with the urls baked into that build. The per-commit snapshot url is still in the sticky comment.deno task devsetsSITE_URL=http://localhost:8000, so development exercises the same code path as a deploy rather than the fallback.Could staticalize do this instead?
Asked, and tested against a miniature site — an HTML page, an
llms.txtand anAGENTS.md, each carrying an absolute url back to itself — crawled by staticalize 0.2.7 (latest) with--base https://frontside.com/effection:index.html<link href>rewritten tohttps://frontside.com/llms.txtllms.txthttp://localhost:8321/api.mdAGENTS.mdhttp://localhost:8321/api.mdTwo things stand out. Text files are not rewritten, which is the reason this PR exists. And
--basedrops its path: I passedhttps://frontside.com/effectionand gothttps://frontside.com/llms.txtback — staticalize copies only scheme, host and port from the base. So even if it learned to rewrite text, it could not produce urls for a site mounted under/effection; that is why the build already passes--base=https://effection.netlify.appand whyuseCanonicalUrl()carries the path separately.Teaching staticalize to rewrite text and to honour the base path would let us delete
SITE_URLlater, and it would be a better fix, since--basewould become the single source of truth. That is a change in another repository, so this PR takes the local route and leaves that door open.Two other things the same experiment turned up, neither of them this PR's business but both worth filing:
<a href>, onlylink[href],[src]and[content].<urls>rather than<url>, which is not the sitemaps.org schema — the deployed sitemap has 519 of them, so search engines are reading a malformed file today.Verification
Served the site under each configuration and read the output: unset →
http://localhost:8000/x/bdd;SITE_URL=https://frontside.com/effection→ urls byte-identical to the current production ones, which matters most forfeed.xml, where a changedguidwould re-flag every post as unread in subscribers' readers;SITE_URL=https://pr-42--effection.netlify.app→ preview urls. Requesting through127.0.0.1underdeno task devstill returnslocalhost:8000, confirmingSITE_URLis in effect rather than the origin fallback. The workflow's compute step, run directly, giveshttps://pr-42--effection.netlify.appfor a branch PR andhttps://effection.netlify.appfor a fork.deno fmt --check(239 files),deno lint(199 files) anddeno task test(38 passed, 244 steps) are clean. The test task gains--allow-env, because the new test reads and clearsSITE_URL.Second of three PRs carved out of #1241.