laravellaravel-9laravel-forge

Laravel Error 500 on a parametric route when in production


I built a small blog where a editor can create articles and post it and users can read it without login.

The issue that I'm having is the following :

In production server, if a user try to access a blog article from the home by clicking on the 'Read more' button, gets a 500 internal server error.

I'm also using other parametric routes and they are working perfectly fine.

In development server, everything works fine.

Any idea of what could the issue's cause?

Thanks in advance

In the home page I'm rendering a list of all the articles via the PublicController's index() method with the following code :

public function index()
    {
        $articles = Article::all();
        return view('welcome', compact('articles'));
    }

And it works perfectly fine.

But when a user click on a item of the list should be redirected, via the 'show()' method of the Public Controller, to the article's details page but in reality the user is getting a 500 internal server error.

The show() method :

public function show($id)
    {
        $article = Article::find($id);
        
        return view('article', compact('article'));
    }

Solution

  • One thing that can help you is to logging the exceptions in your Handler.php file. This way you can see the error details (message, file and code line).