Source: https://jtpck.com/blog/solving-hotwire-native-406-unsupported-browser-error

# Solving the Hotwire Native 406 Unsupported Browser Error

Learn how to fix the Rails 8.0 allow_browser feature blocking Hotwire Native WebViews and resolve the 406 unsupported browser error in your iOS app.

By JTPCK Team · Nov 8, 2025

In a recent update to a Ruby on Rails 8.0 application, I encountered an issue triggered by the new `allow_browser` feature in Rails. This feature is designed to block unsupported or outdated browsers from accessing the app by checking their user agent. However, this became problematic in a Hotwire Native setup where the app's iOS WebKit view was mistakenly flagged as unsupported.
<br>
<br>
The issue first surfaced through a Sentry monitoring alert showing an `ArgumentError`:
<br>
<br>

```
ArgumentError: File /app/public/406-unsupported-browser.html does not exist
```

<br>
<br>
The stack trace pointed to Rails attempting to render a static error page that wasn't present in the `/public` directory. This happens when `allow_browser` determines that the client's browser doesn't meet the version criteria. By default, the method tries to serve a `406-unsupported-browser.html` file, which is not created automatically.
<br>
<br>

<br>
After tracing the error, I found the culprit inside `rails/app/controllers/application_controller.rb`. 
<br>
<br>
The controller included the following line:
<br>
<br>

```ruby
class ApplicationController < ActionController::Base
  include Pundit::Authorization

allow_browser versions: :modern

end

```

<br>
<br>
The `allow_browser` method was apparently rejecting my iOS Hotwire Native WebView as an outdated browser. Since this WebView runs inside a controlled environment using modern WebKit, the restriction wasn't necessary.
<br>
<br>
Removing this configuration resolved the problem immediately. The updated file now looks like this:
<br>
<br>

With the `allow_browser versions: :modern` line removed, the application no longer checks browser compatibility at the framework level. This means all browsers, including embedded WebViews, can access the app without triggering a 406 error. In a Hotwire Native environment, this is the correct behavior because the WebView environment is already known, consistent, and secure.
<br>
<br>
If in the future you want to enforce browser restrictions, you could either create a custom `406-unsupported-browser.html` file under `/public` or configure `allow_browser` with a custom block that excludes specific user agents. For example:
<br>
<br>

```ruby
allow_browser do |browser|
  browser.modern? || browser.user_agent.include?("MyHotwireApp")
end
```

<br>
<br>
This approach allows you to maintain browser filtering while explicitly allowing your Hotwire Native app to bypass the check.
