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 3000The 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.
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"inconfig/environments/development.rb. Rails checksX-Forwarded-Hostas well asHost.- Without it
- A
403page headedBlocked 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-HostandX-Forwarded-Proto. Mailer links stay onlocalhost:3000untildefault_url_optionssays 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"
endRestart 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
Add the tunnel's domain to config.hosts in config/environments/development.rb and restart the server. For whk share that is config.hosts << ".sharehooks.cc"; the leading dot allows every name under the domain. Rails checks the X-Forwarded-Host header as well as Host, which is why a tunnel that sends Host: localhost is still blocked.
No. The link is HTTPS for the visitor and passes X-Forwarded-Proto: https, which Rails reads when it builds URLs and checks a form's origin. force_ssl and assume_ssl are for production setups.
Rails reloads your code on the next request, so visitors get your latest edit when they load or reload a page. A default Rails app has no browser live reload. WebSockets pass through the link, so Action Cable and Turbo Streams work.
3000 by default. bin/rails server -p 4000 picks another, and the PORT environment variable is read when -p is not given. Share whichever port the server prints.
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
Send someone your Ruby on Rails app
Sign up free, install the CLI and run whk share 3000.
No credit card