where('is_active', true) ->first(); if (! $website) { return response('', 404) ->header('Content-Type', 'application/javascript'); } // Use ad-blocker resistant endpoint if script is loaded from /cdn/resources/ // Otherwise use the original endpoint for backward compatibility $currentRoute = request()->route()->getName(); // $collectUrl = $currentRoute === 'tracking.script.alt' // ? 'route('collect.store.alt')' // : route('collect.store'); $collectUrl = 'https://assets.libremetrics.com/assets/client/data'; $js = view('tracking.tracker', [ 'trackingId' => $trackingId, 'collectUrl' => $collectUrl, ])->render(); return response($js) ->header('Content-Type', 'application/javascript') ->header('Cache-Control', 'public, max-age=3600'); } }