Skip to content

Let the site run locally over plain http - #570

Merged
simonhamp merged 1 commit into
mainfrom
fix/local-http
Oct 23, 2026
Merged

simonhamp merged 1 commit into
mainfrom
fix/local-http

Conversation

@simonhamp

Copy link
Copy Markdown
Member

A fresh clone or worktree served by Herd at http://<folder>.test shows a blank white page until you run herd secure. This lets it render over plain http.

Why it was blank

All three layouts (layout, layouts/auth, layouts/dashboard) have this in the head:

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />

Laravel builds asset URLs from the current request, so the page asks for http://<folder>.test/build/assets/.... The CSP tells the browser to fetch those over https instead. A site that hasn't been secured has no certificate, so every CSS and JS request fails. Alpine never boots, and because <body> has x-cloak, Livewire's [x-cloak] { display: none } rule keeps the whole page hidden. The HTML is all there, you just can't see it.

Nothing in the app forces https (no forceScheme, no HSTS). The main checkout only redirects to https because Herd does that for secured sites.

The fix

The meta tag is now left out when APP_ENV is local. Every other environment still gets it, so production behaves exactly as before. I kept it outside local on purpose: TrustProxies trusts no proxies, so if production sits behind something that terminates TLS, Laravel probably sees plain http and builds http asset URLs. The CSP meta is likely what stops those being blocked as mixed content there.

Secured local sites (herd secure) still work, since their asset URLs are already https.

Testing

  • Reproduced the blank page at http://nativephp.com--local-http.test/docs/mobile/4/the-basics/routing. All five CSS and JS requests went to https and failed.
  • With the change, the same URL and /login render normally with no failed requests.
  • New UpgradeInsecureRequestsTest checks the main, auth and dashboard layouts include the meta in production and leave it out locally.
  • Full suite: 2039 passed, 2 failed, 1 skipped. The two failures (PluginSyncServiceTest "Could not discover latest release" log count, and SupportTicketTest "only internal notes can be pinned") fail the same way on a clean origin/main checkout, so they are not from this change.

🤖 Generated with Claude Code

The upgrade-insecure-requests CSP meta made the browser fetch every
asset over https. On a Herd site that hasn't been secured those
requests fail, Alpine never loads, and the x-cloak on <body> keeps the
page blank. Leave the meta out when APP_ENV is local so a fresh clone
or worktree can be previewed over plain http. Other environments still
get it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonhamp
simonhamp marked this pull request as ready for review October 23, 2026 11:20
@simonhamp
simonhamp merged commit 9827b61 into main Oct 23, 2026
2 of 3 checks passed
@simonhamp
simonhamp deleted the fix/local-http branch October 23, 2026 11:20
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