diff --git a/config/telescope.php b/config/telescope.php index 7585f3673..284f57379 100644 --- a/config/telescope.php +++ b/config/telescope.php @@ -80,6 +80,21 @@ Authorize::class, ], + /* + |-------------------------------------------------------------------------- + | Allowed Paths + |-------------------------------------------------------------------------- + | + | The following array lists the URI paths be watched by Telescope. + | NOTE: Specifying any paths in this list + | ignores all paths specified in 'ignore_paths' below. + | + */ + + 'only_allow_paths' => [ + // 'api/*' + ], + /* |-------------------------------------------------------------------------- | Ignored Paths & Commands diff --git a/src/Telescope.php b/src/Telescope.php index ad877eb21..dc0ab7ae6 100644 --- a/src/Telescope.php +++ b/src/Telescope.php @@ -186,7 +186,17 @@ protected static function runningApprovedArtisanCommand($app) */ protected static function handlingApprovedRequest($app) { - return ! $app->runningInConsole() && ! $app['request']->is( + if ($app->runningInConsole()) { + return false; + } + + // Prioritize only_allow_paths if any are specified + $onlyAllowed = config('telescope.only_allow_paths', []); + if (! empty($onlyAllowed)) { + return $app['request']->is($onlyAllowed); + } + + return ! $app['request']->is( array_merge([ config('telescope.path').'*', 'telescope-api*',