Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1401b53

Browse files
AhmedAlaa4611taylorotwell
andauthored
[12.x] Add allowedUrls through preventStrayRequests (#10781)
* Add allowedUrls through preventStrayRequests * Update http-client.md --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 7cec74a commit 1401b53

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎http-client.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,24 @@ Http::get('https://github.com/laravel/framework');
823823
Http::get('https://laravel.com');
824824
```
825825

826+
Sometimes, you may wish to prevent most stray requests while still allowing specific requests to execute. To accomplish this, you may pass an array of URL patterns to the `allowStrayRequests` method. Any request matching one of the given patterns will be allowed, while all other requests will continue to throw an exception:
827+
828+
```php
829+
use Illuminate\Support\Facades\Http;
830+
831+
Http::preventStrayRequests();
832+
833+
Http::allowStrayRequests([
834+
'http://127.0.0.1:5000/*',
835+
]);
836+
837+
// This request is executed...
838+
Http::get('http://127.0.0.1:5000/generate');
839+
840+
// An exception is thrown...
841+
Http::get('https://laravel.com');
842+
```
843+
826844
<a name="events"></a>
827845
## Events
828846

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /