40% off on Spike Billing!

Configuring middleware

Before you're able to configure this, make sure to first publish the configuration file.

Since Log Viewer v2, the requests can be stateless and no longer have any middleware requirements, but the default configuration (config/log-viewer.php) does include some middleware to make sure authorization works out of the box, which is described below.

You can easily add your own Laravel Middleware. This will only take effect when loading the Log Viewer UI.

    /*    |--------------------------------------------------------------------------    | Log Viewer route middleware.    |--------------------------------------------------------------------------    | Optional middleware to use when loading the initial Log Viewer page.    |    */    'middleware' => [        'web',        \Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class,    ],    

Here are the default middlewares:

  • The web middleware group makes sure your requests are stateful and can resolve an authenticated user for authorization. Refer to your app/Http/Kernel.php file to see which middlewares are included in the web middleware group.
  • The AuthorizeLogViewer middleware makes sure that only authorized users can access the Log Viewer. You still need to configure the authorization rule described here.

API middleware

You can also add your own Laravel Middleware to the Log Viewer API requests.

    /*    |--------------------------------------------------------------------------    | Log Viewer API middleware.    |--------------------------------------------------------------------------    | Optional middleware to use on every API request. The same API is also    | used from within the Log Viewer user interface.    |    */    'api_middleware' => [        \Opcodes\LogViewer\Http\Middleware\EnsureFrontendRequestsAreStateful::class,        \Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class,    ],    

Here are the default middlewares:

  • The EnsureFrontendRequestsAreStateful middleware makes sure that API requests from the Log Viewer user interface are stateful. This is required for authorization to work properly when navigating the logs. You can remove this middleware if you don't need authorization.
  • The AuthorizeLogViewer middleware makes sure that only authorized users can access the Log Viewer. You still need to configure the authorization rule described here.

Support

If you have any questions, feedback, or need any help setting up Log Viewer within your project, feel free to reach out via GitHub Discussions or GitHub Issues .