bepsvpt/secure-headers

Problem with middleware SecureHeadersMiddleware.php

oleg-tolkach opened this issue · 4 comments

Sometimes I have the next error in log file
Trying to get property of non-object in /public_html/vendor/bepsvpt/secure-headers/src/SecureHeadersMiddleware.php:26

I think variable $response has not property headers and it born an exception

Hi @oleg-tolkach,

What is your Laravel version and is there any way to reproduce this bug?

--

I found some similar problems at stackoverflow, please tell me that they are same as your case or not.

Hi @oleg-tolkach,

After seeing this problem in other place, I guess it is because of missing return value from other middleware.

The following middleware will result in exception you had encountered.

public function handle($request, Closure $next)
{
    if (false /* some condition check */) {
        return $next($request);
    }
}

Thus, you should ensure that all middleware have return value.

Closed due to inactivity, feel free to open a new issue if you have any question.