fix(dev-lan): unblock phone-on-LAN testing of the dev server
Branding URLs were baked with env.APP_URL=http://localhost:3000 at upload time and stored verbatim in system_settings, so any logo/ background loaded from a non-localhost origin (an iPhone hitting the Mac's LAN IP) failed to resolve. Same pattern bit Socket.IO (CORS + client connection target) and the portal logout redirect. - Branding: getPortBrandingConfig normalizes localhost/private-LAN hosts to path-only; both upload routes store path-only going forward; email shell re-absolutizes via absolutizeBrandingUrl() so inboxes (no app origin) still get fetchable URLs. DB backfilled to strip http://localhost:3000 from existing rows. - Socket.IO: client connects to window.location.origin (io() with no URL); server CORS allows localhost + private-LAN ranges in dev, stays locked to APP_URL in prod. - Portal logout: redirect target built from the request URL instead of env.APP_URL. - next.config: allowedDevOrigins widened from a hardcoded IP to 192.168/10/172.16-31 wildcards so HMR works across networks without an edit per-network. (Without HMR the login form's React click handler never hydrates and the form falls back to GET, leaking the password into the URL.) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -84,11 +84,13 @@ const nextConfig: NextConfig = {
|
||||
// visible in every screenshot from the iPhone testing pass.
|
||||
devIndicators: false,
|
||||
// LAN access from a real iPhone hits the dev server via the Mac's
|
||||
// local IP (e.g. 192.168.x.x), not localhost. Next 15 surfaces a
|
||||
// warning for cross-origin /_next/* fetches unless we allow-list the
|
||||
// origins explicitly. Wildcard the 192.168/0.0.0.0 ranges in dev so
|
||||
// any LAN device works without a config edit per network.
|
||||
...(isProd ? {} : { allowedDevOrigins: ['192.168.1.42'] }),
|
||||
// local IP (e.g. 192.168.x.x), not localhost. Next surfaces a warning
|
||||
// and blocks cross-origin /_next/* fetches (incl. HMR) unless we
|
||||
// allow-list the origins explicitly. When HMR is blocked the page
|
||||
// never fully hydrates and form click handlers fall back to native
|
||||
// submits — the symptom that bit us with a hard-coded IP. Wildcards
|
||||
// cover any LAN device without a per-network config edit.
|
||||
...(isProd ? {} : { allowedDevOrigins: ['192.168.*.*', '10.*.*.*', '172.16.*.*', '172.20.*.*'] }),
|
||||
// Native/CJS-leaning server-only packages — list here so Next doesn't
|
||||
// bundle them into the route trace (slower cold start + risk that
|
||||
// native bindings fail at runtime). Build-auditor C3+M3: socket.io
|
||||
|
||||
Reference in New Issue
Block a user