Man
4 years ago

Getting errors in production only

Posted 4 years ago by Man

I set up a sidebar to get posts in the same category:

$post_category = Post::find($post->post_category_id);
$sidebar = Post::where('published', '=', '1')->where('post_category_id', '=', $post_category->id)->orderBy('created_at', 'DESC')->take(6)->get();

Everything works well locally. But when I push it to production, I get an error:

ErrorException Trying to get property of non-object
    public/content/includes/sidebar.php:4 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
    public/content/includes/sidebar.php:4 include
    public/content/post.php:89 include
    vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php:42 Illuminate\View\Engines\PhpEngine::evaluatePath
    vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php:20 Illuminate\View\Engines\PhpEngine::get
    vendor/laravel/framework/src/Illuminate/View/View.php:138 Illuminate\View\View::getContents
    vendor/laravel/framework/src/Illuminate/View/View.php:107 Illuminate\View\View::renderContents
    vendor/laravel/framework/src/Illuminate/View/View.php:81 Illuminate\View\View::render
    vendor/laravel/framework/src/Illuminate/Http/Response.php:51 Illuminate\Http\Response::setContent
    vendor/symfony/http-foundation/Response.php:202 Symfony\Component\HttpFoundation\Response::__construct
    vendor/laravel/framework/src/Illuminate/Routing/Router.php:1225 Illuminate\Routing\Router::prepareResponse
    vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:113 Illuminate\Routing\ControllerDispatcher::Illuminate\Routing\{closure}
    [internal]:0 call_user_func
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:139 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    app/Http/Middleware/Secure.php:35 App\Http\Middleware\Secure::handle

How is this possible. The only difference between local and production is that production uses SSL. I have cloudfront set up to forward all http request to https.

Please sign in or create an account to participate in this conversation.