Skip to content

Commit

Permalink
#760 - exclude http methods from processing to solve 'POST not workin…
Browse files Browse the repository at this point in the history
…g' issue
  • Loading branch information
baltun7 committed Nov 17, 2020
1 parent 8e7014d commit f1c06b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@ will not work. Instead, one has to use
</form>
```


Another way to solve this is to put http method to config to 'laravellocalization.httpMethodsIgnored'
to prevent of processing this type of requests

### MethodNotAllowedHttpException

If you do not localize your post url and use a redirect middleware,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class LaravelLocalizationMiddlewareBase
*/
protected function shouldIgnore($request)
{
if (in_array($request->method(), config('laravellocalization.httpMethodsIgnored'))) {
return true;
}
$this->except = $this->except ?? config('laravellocalization.urlsIgnored', []);
foreach ($this->except as $except) {
if ($except !== '/') {
Expand Down
1 change: 1 addition & 0 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,5 @@
// Defaults to []
'urlsIgnored' => ['/skipped'],

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

0 comments on commit f1c06b8

Please sign in to comment.