Skip to content

Share localhost / Ruby on Rails

Share a Rails dev server at a public URL

bin/rails server listens on localhost:3000, and whk share 3000 gives it an HTTPS link. Rails is one of the few frameworks that needs a line of configuration first, because its host check reads the forwarded host too.

# terminal 1: the dev server
bin/rails server

# terminal 2: the link
whk share 3000

The link is https://<name>.sharehooks.cc and works until you press Ctrl-C. No whk yet? Install it and log in, which takes a minute.

Start free:
or sign up with email

Ruby on Rails at a glance

Dev server
bin/rails server, port 3000
Share it
whk share 3000
Setting to add
config.hosts << ".sharehooks.cc" in config/environments/development.rb. Rails checks X-Forwarded-Host as well as Host.
Without it
A 403 page headed Blocked hosts: <name>.sharehooks.cc, and the same words in the server log.
Hot reload
Rails reloads changed code before the next request, so a visitor sees your edit on their next page load. There is no browser reload in a default app.
URLs and cookies
URLs and redirects use the public name: Rails reads X-Forwarded-Host and X-Forwarded-Proto. Mailer links stay on localhost:3000 until default_url_options says otherwise.

Your dev server gets each request with Host: localhost:3000; the public name travels in X-Forwarded-Host, with X-Forwarded-Proto: https. What your server sees has the rest.

Allow the preview in config.hosts

In development Rails only answers hosts it knows: localhost, names under .localhost and .test, and IP addresses. The link sends Host: localhost:3000, which passes, but ActionDispatch::HostAuthorization also checks the last value of X-Forwarded-Host, and that is your preview's name. So the first request through a share gets 403 Forbidden and a page that starts Blocked hosts: <name>.sharehooks.cc.

Add the domain to the development environment. A leading dot permits the domain and every name under it, so one line covers random names and reserved ones:

config/environments/development.rb

Rails.application.configure do
  # Previews opened with whk share
  config.hosts << ".sharehooks.cc"
end

Restart the server afterwards: environment files are read at boot. With a reserved name you can list just that name (config.hosts << "acme.sharehooks.cc"), which keeps other people's previews out of the list.

Forms, redirects and Action Cable

Rails builds request.base_url from X-Forwarded-Host and X-Forwarded-Proto, so inside a request the app believes it is at https://<name>.sharehooks.cc. The CSRF origin check (forgery_protection_origin_check) compares the form's Origin with that, and they match; redirect_to and *_url helpers point at the link.

Action Cable accepts origins matching /https?:\/\/localhost:\d+/ in development. The link sends a WebSocket's Origin as http://localhost:3000, so /cable connects without changing allowed_request_origins, and Turbo Streams keep arriving.

What visitors see when something raises

Development shows full error pages, source lines included, to whoever makes the request, so a visitor who hits an exception sees it. The interactive console on those pages is another matter: web-console only renders for local addresses and reads the forwarded client address, so a visitor does not get it, and your log says Cannot render console from <address>!.

Mailers have no request to read a host from. The generated development.rb sets config.action_mailer.default_url_options = { host: "localhost", port: 3000 }, so links in emails sent while you share still point at localhost. Change it if someone else needs to click them.

Ruby on Rails questions

Sources

The Ruby on Rails settings and messages on this page are from the official documentation and source for Ruby on Rails 8.1, read on 12 November 2026. What the link does to a request is from the whk share docs.

Other frameworks

All 14 framework guides

Send someone your Ruby on Rails app

Sign up free, install the CLI and run whk share 3000.

or sign up with email

No credit card