Catch/ignore “Method OPTIONS is not allowed”

vcernik
Member | 32
+
0
-

Hi,
sometimes happens Nette\Application\BadRequestException #405: Method OPTIONS is not allowed.

I know this: https://doc.nette.org/…n/presenters#…
But I don't use this method, I don't need it, so I don't want to add it do allowed methods.

But somebody is sending requests using method OPTIONS and then I am getting these exceptions :(

How to catch/ignore this exception?

m.brecher
Generous Backer | 840
+
0
-

Hi, all 4xx exceptions including 405 shouldnt be logged, they only should be processed with a proper 4xx error presenter and 4xx error page. You cannot block somebodys requests to nonexisting urls or not allowed methods in your application. Simply ignore them.

Last edited by m.brecher (2024-06-28 21:47)

Gappa
Nette Blogger | 206
+
+3
-

These changes in ErrorPresenter4xx should fix it:

vcernik
Member | 32
+
+1
-

Gappa wrote:

These changes in ErrorPresenter4xx should fix it:

Thank you, it works!