Skip to content

Conversation

@negoziator
Copy link
Contributor

feat: allow overriding the request hostname

Fixes subdomain routing for Laravel Sail and multitenant applications by allowing custom host configuration.

Problem

Browser tests fail with subdomain routing because the server was hardcoded to bind to 127.0.0.1, preventing proper subdomain resolution.

Solution

This approach is almost the same as the one that got merged: #128

However, instead of modifying HTTP headers, this implementation addresses the root cause by allowing the server binding host to be configured via a new withHost() method that follows the same pattern as userAgent().

Usage

pest()->browser()->withHost('tenant.localhost');
visit('/dashboard')->assertSee('Welcome to tenant dashboard');

#1593 - Browser testing with subdomains and Laravel Sail
#1443 - Browser testing doesn't work for domain based routing
#1520 - Browser tests for subdomains point to local environment
#1476 - Make it possible to set custom Host header for browser tests

@nunomaduro nunomaduro merged commit 631aeed into pestphp:4.x Jan 7, 2026
0 of 2 checks passed
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.

2 participants