Skip to content

Conversation

@rabrowne85
Copy link
Contributor

The purpose behind Http::preventStrayRequests() is great - it stops any stray requests from hitting endpoints.
However, this also means that if you’re trying to use SSR to check the output from something like Inertia, those requests will be blocked and a StrayRequestException will be thrown.

This PR expands the existing Http::allowStrayRequests() method to accept an array of “allowed” URLs.
For example:

Http::allowStrayRequests([ 'http://127.0.0.1:13714/*', ]);

To keep things fully backward-compatible, calling allowStrayRequests() without arguments still turns preventStrayRequests off entirely, as it did before.

Both the Http\Client\Factory and Http\Client\PendingResponse classes have been adjusted to accept and pass the allowed list of URLs.

I’ve added a simple test to ensure the allow-list logic works.
I avoided adding a test that actually hits a real endpoint, since depending on when/how the tests are run, the result could vary - even for 127.0.0.1.

@github-actions
Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@rabrowne85 rabrowne85 marked this pull request as ready for review August 13, 2025 15:49
@taylorotwell taylorotwell merged commit a97fa06 into laravel:12.x Aug 13, 2025
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants