Skip to content

Commit

Permalink
feat: Add internal preview url middleware config
Browse files Browse the repository at this point in the history
  • Loading branch information
pboivin committed Oct 1, 2023
1 parent 9f52303 commit 9f137c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions config/filament-peek.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@

'useInternalPreviewUrl' => false,

'internalPreviewUrlMiddleWare' => [],

/*
|--------------------------------------------------------------------------
| Builder Editor
Expand Down
16 changes: 9 additions & 7 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
use Pboivin\FilamentPeek\CachedPreview;

if (config('filament-peek.useInternalPreviewUrl', false)) {
Route::prefix('filament-peek')->group(function () {
Route::get('preview', function () {
abort_unless($token = Request::query('token'), 404);
Route::prefix('filament-peek')
->middleware(config('filament-peek.internalPreviewUrlMiddleWare', []))
->group(function () {
Route::get('preview', function () {
abort_unless($token = Request::query('token'), 404);

abort_unless($preview = CachedPreview::get($token), 404);
abort_unless($preview = CachedPreview::get($token), 404);

return $preview->render();
})->name('filament-peek.preview');
});
return $preview->render();
})->name('filament-peek.preview');
});
}

0 comments on commit 9f137c3

Please sign in to comment.