Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#760 - exclude http methods from processing to solve 'POST not working' issue #762

Merged
merged 1 commit into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'],
];