Skip to content

Commit 40b7b81

Browse files
committed
feat(cloudflare-cache-header-middleware): handle $request->route() returning null
1 parent 6230af4 commit 40b7b81

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

app/Http/Middleware/CloudflareCacheHeaderMiddleware.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ public function handle(Request $request, Closure $next)
1212
{
1313
/** @var Response $response */
1414
$response = $next($request);
15+
$routeUri = data_get($request->route(), 'uri');
1516

16-
if (Str::startsWith($request->route()->uri, 'api/')) {
17+
if (Str::startsWith($routeUri, 'api/')) {
1718
// Cache all responses for 1 minute
1819
$response->setCache(['public' => true, 'max_age' => 60, 's_maxage' => 60]);
1920

0 commit comments

Comments
 (0)