Skip to content

Conversation

@jayohms
Copy link
Contributor

@jayohms jayohms commented Jan 5, 2026

To support mobile devices pointed to a local development machine, this:

  • Binds local development to 0.0.0.0 for nip.io support
  • Configures the host for development

This change depends on #2291 for non-secure write requests.

/fizzy-\d+/, # review apps: fizzy-123, fizzy-456:3000
/.*\.ts\.net/ # tailscale serve: hostname.tail1234.ts.net
/fizzy-\d+/, # review apps: fizzy-123, fizzy-456:3000
/.*\.ts\.net/, # tailscale serve: hostname.tail1234.ts.net

Check failure

Code scanning / CodeQL

Missing regular expression anchor High

When this is used as a regular expression on a URL, it may match anywhere, and arbitrary hosts may come before or after it.

Copilot Autofix

AI 4 days ago

In general, to fix missing-anchor issues, change regexes so they match the entire intended value rather than any substring, using \A and \z (or ^ and $ only when line-based behavior is explicitly desired). For hostnames, you usually want “host ends with .example.com” or similar, not “string contains .example.com somewhere”.

Here, config.hosts should allow any host under the ts.net domain. The simplest, least-disruptive fix is to replace /.*\.ts\.net/ with an anchored pattern that still allows any subdomain but ensures .ts.net is at the end of the host (ignoring an optional port). For example:

  • Use \A and \z to anchor the whole host string.
  • Permit an optional :<port> after the hostname to match how Rails may include ports in config.hosts.
  • Keep the comment semantics (“hostname.tail1234.ts.net”) intact.

A robust replacement is:

/\A.*\.ts\.net(?::\d+)?\z/

This matches any string that:

  • Starts with anything ending in .ts.net
  • Optionally has :PORT after it
  • Has no trailing extra characters.

Concretely, in config/environments/development.rb, line 93 should be changed from /.*\.ts\.net/ to /\A.*\.ts\.net(?::\d+)?\z/. No new imports or methods are needed; it’s a direct regex literal change.

Suggested changeset 1
config/environments/development.rb

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/config/environments/development.rb b/config/environments/development.rb
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -89,9 +89,9 @@
     "fizzy.localhost",
     "localhost",
     "127.0.0.1",
-    /fizzy-\d+/,   # review apps: fizzy-123, fizzy-456:3000
-    /.*\.ts\.net/, # tailscale serve: hostname.tail1234.ts.net
-    /.*\.nip\.io/  # nip.io for mobile apps
+    /fizzy-\d+/,                    # review apps: fizzy-123, fizzy-456:3000
+    /\A.*\.ts\.net(?::\d+)?\z/,     # tailscale serve: hostname.tail1234.ts.net
+    /.*\.nip\.io/                   # nip.io for mobile apps
   ]
 
   # Canonical host for mailer URLs (emails always link here, not personal Tailscale URLs)
EOF
@@ -89,9 +89,9 @@
"fizzy.localhost",
"localhost",
"127.0.0.1",
/fizzy-\d+/, # review apps: fizzy-123, fizzy-456:3000
/.*\.ts\.net/, # tailscale serve: hostname.tail1234.ts.net
/.*\.nip\.io/ # nip.io for mobile apps
/fizzy-\d+/, # review apps: fizzy-123, fizzy-456:3000
/\A.*\.ts\.net(?::\d+)?\z/, # tailscale serve: hostname.tail1234.ts.net
/.*\.nip\.io/ # nip.io for mobile apps
]

# Canonical host for mailer URLs (emails always link here, not personal Tailscale URLs)
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails add the anchors, confusingly.

@jayohms jayohms requested a review from jeremy January 5, 2026 16:48
@jayohms jayohms merged commit 4919e57 into main Jan 6, 2026
12 checks passed
@jayohms jayohms deleted the mobile-local-dev branch January 6, 2026 14:05
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.

3 participants