GitHub Codespaces
ModelRails runs in a browser-hosted GitHub Codespace using the same .devcontainer/ config as a local Dev Container. A Codespace runs that container on a cloud VM and reaches the app through a forwarded HTTPS proxy at https://<codespace-name>-<port>.app.github.dev instead of localhost.
Quickstart
- On the repo’s GitHub page: Code → Codespaces → Create codespace. The first build runs
.devcontainer/setup.sh(system packages,bin/setup) — a few minutes. - In the Codespace terminal:
bin/dev. - Open the app: the Ports panel forwards port 3000 — click its URL (or the auto-forward notification). Do not use
http://localhost:3000. - Sign in: ModelRails is passwordless. Request a magic link, then read it in the dev mail inbox at
/letter_openeron your forwarded port 3000 URL (dev never sends real email —letter_opener_webmounts there). The link targets the forwarded domain, so it resolves in the browser.
Why the Codespaces-specific config exists
Three localhost-only assumptions break when the origin becomes *.app.github.dev, so config/environments/development.rb adapts when CODESPACES=true (see lib/codespaces.rb):
- Host authorization. Rails’ DNS-rebinding protection allows only
localhost/IPs by default and returns403 Blocked hostfor the forwarded domain. The Codespaces block adds.app.github.devtoconfig.hosts. - Mailer link host. Magic-link emails are built from
config.action_mailer.default_url_options. In a Codespace that host is set to the forwarded URL (HTTPS, with the port baked into the subdomain) so sign-in links work from the browser. - The CSRF Origin check. Rails compares the browser’s
Originwith the app’s own base URL before it looks at anything else. Behind the forwarded proxy, and through VS Code’slocalhostport-forward, the two never match (http://localhost:3000againsthttps://<codespace>-3000.app.github.dev), so every form post (magic-link sign-in, the docs audience switcher, cookie consent) would fail with 422. The Codespaces block turns off only that comparison. Writes are still verified by the browser’sSec-Fetch-Siteheader, which a page and a form on the same forwarded URL always send assame-origin(see Security, Cross-Site Request Forgery).
The server already binds correctly: .devcontainer/devcontainer.json sets BINDING=0.0.0.0, which rails server needs to be reachable through the forward (its development default is localhost).
Running the test suite
bin/ci and the Cuprite/axe system specs run entirely in-container against 127.0.0.1, so they need no Codespaces-specific configuration. The default 2-core Codespace runs the full suite but slowly — if you run bin/ci often, bump the machine type from the Codespaces UI (Change machine type).
Out of scope
Passkeys (WebAuthn) over the Codespaces origin and Kamal/Docker builds from inside a Codespace are not configured here.