Skip to content

fix(website): site links always end in a slash so images load on Filebase - #127

Merged
ehsan6sha merged 1 commit into
mainfrom
fix/site-links-trailing-slash
Sep 16, 2026
Merged

ehsan6sha merged 1 commit into
mainfrom
fix/site-links-trailing-slash

Conversation

@ehsan6sha

Copy link
Copy Markdown
Member

Bug

Images on generated sites don't load when opened from the app's Open / Copy URL links on Filebase.

Root cause (measured, not inferred)

  1. WebsiteGeneration.gatewayUrl produced https://ipfs.filebase.io/ipfs/<cid>no trailing slash. From there the site's relative asset ref ../<asset> resolves to /<asset>404.
  2. The inline fallback that should rescue it is blocked by Filebase's CSP (default-src 'self', no script-src). Browser-verified: inline script didn't run, script-src-elem violation; reported image naturalWidth 0, data-fx-try never set.

Same site with the slash: image loads at 1920px from Filebase, no script needed.

Fix

The getter always returns a slashed URL. It is the single chokepoint for every page link (Open, Copy URL, websites-list fallback, social caption fallback, contact-form check, native status card). publicGatewayUrlForCid is untouched — it also builds public file-share links, which must stay bare; a test pins that.

Not covered here

Links already copied without a slash; server-emitted URLs (public directory fallback) — separate server PR.

Testing

8 new tests (both template shapes, custom template, no double slash, relative ref resolves onto the gateway, file shares stay bare) · 1089 Flutter · flutter build web --release ✓ · analyzer clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AwMWmCivEpYTmmzzmjSTAf

…base

Published sites reference their assets relatively (../<cid>). That resolves
correctly only from the slashed page URL:

  https://ipfs.filebase.io/ipfs/<page>    ../<asset> -> /<asset>        404
  https://ipfs.filebase.io/ipfs/<page>/   ../<asset> -> /ipfs/<asset>   200

WebsiteGeneration.gatewayUrl -- behind every Open, Copy URL, list fallback,
social caption, contact-form check and the native status card -- built the
unslashed form for path-style templates. With dweb (subdomain, root already
slashed) this never showed; making Filebase the default silently changed the
link shape.

The published fallback that should rescue an unslashed page is an inline
script, and Filebase blocks inline scripts: it sends
  Content-Security-Policy: default-src 'self'; img-src * ...; style-src * ...
with no script-src. Verified in a real browser on 2026-09-16 -- an inline
script inserted into a Filebase page did not run and raised a
script-src-elem violation; the reported site's image was complete with
naturalWidth 0 and data-fx-try never set. So on the default gateway the slash
is the only thing that makes a site's images load. Same site with the slash:
image 1920px wide, served from Filebase, no script involved.

The slash is applied in this getter only. publicGatewayUrlForCid also builds
public FILE-share links, and asset URLs are files; both stay bare. A test pins
that distinction. Subdomain templates already end in '/', so this is a no-op
there.

This does not reach links already copied without a slash, nor server-emitted
URLs (the public directory falls back to a stored unslashed gateway_url); the
server side is fixed separately.

Tests: 8 new; 1089 Flutter passing; web release build; analyzer clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AwMWmCivEpYTmmzzmjSTAf
@ehsan6sha
ehsan6sha merged commit dd06cb6 into main Sep 16, 2026
2 of 3 checks passed
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.

1 participant