Skip to content

Commit c71bb11

Browse files
baltunbaltun7
andauthored
#760 - exclude http methods from processing to solve 'POST not working' issue (#762)
Co-authored-by: Ilya Kolesnikov <ivkol@mail.ru>
1 parent 204c3ae commit c71bb11

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,10 @@ will not work. Instead, one has to use
508508
</form>
509509
```
510510

511+
512+
Another way to solve this is to put http method to config to 'laravellocalization.httpMethodsIgnored'
513+
to prevent of processing this type of requests
514+
511515
### MethodNotAllowedHttpException
512516

513517
If you do not localize your post url and use a redirect middleware,

src/Mcamara/LaravelLocalization/Middleware/LaravelLocalizationMiddlewareBase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class LaravelLocalizationMiddlewareBase
2020
*/
2121
protected function shouldIgnore($request)
2222
{
23+
if (in_array($request->method(), config('laravellocalization.httpMethodsIgnored'))) {
24+
return true;
25+
}
2326
$this->except = $this->except ?? config('laravellocalization.urlsIgnored', []);
2427
foreach ($this->except as $except) {
2528
if ($except !== '/') {

src/config/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,5 @@
344344
// Defaults to []
345345
'urlsIgnored' => ['/skipped'],
346346

347+
'httpMethodsIgnored' => ['POST', 'PUT', 'PATCH', 'DELETE'],
347348
];

0 commit comments

Comments
 (0)