Use Service Worker in Plugin I am currently working on a plugin that uses a service worker which gets registered  on the front-end by some javascript code and the problem is that the service worker scope is restricted to /cpresources/610c42da/ as the Asset Manager only serves the file from there.  

Here's the code which I currently use to integrate with the front-end:

Craft::$app-&gt;getView()
                   -&gt;hook('cachecraft', function () {
                       // Pass the service worker url to the site
                       Craft::$app-&gt;getView()
                                  -&gt;registerScript(
                                      'const CACHECRAFT_SERVICE_WORKER = "' .
                                      Craft::$app-&gt;assetManager-&gt;getPublishedUrl('@skayo/cachecraft/assetbundles/cachecraft/dist/js/service-worker.js', true) .
                                      '";',
                                      1,
                                      [],
                                      'cachecraft_service_worker'
                                  );

                       // Register asset bundle
                       Craft::$app-&gt;getView()
                                  -&gt;registerAssetBundle(CacheCraftAsset::class);
                   });


So what I need is to serve my service worker from the root (https://example.com/service-worker.js) of the website.
Is that possible somehow?
Another possible way is to serve the file normally at https://example.com/cpresources/610c42da/service-worker.js BUT with a Service-Worker-Allowed HTTP Header.
But I don't know how to do that either...

Thanks in advance for any help!
Solved it by just serving the file within a controller action like this:

public function actionCacheCraftServiceWorker () {
    $serviceWorkerFile = Craft::getAlias('@skayo/cachecraft/assetbundles/cachecraft/dist/js/CacheCraftServiceWorker.min.js');

    return Craft::$app-&gt;getResponse()-&gt;sendFile(
        $serviceWorkerFile,
        'CacheCraftServiceWorker.min.js',
        [
            'mimeType' =&gt; 'application/javascript',
            'inline' =&gt; true
        ]
    );
}


and using this event to register the front-end url:

Event::on(
    UrlManager::class,
    UrlManager::EVENT_REGISTER_SITE_URL_RULES,
    function (RegisterUrlRulesEvent $event) {
        Craft::debug(
            'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
            __METHOD__
        );
        $event-&gt;rules['cache-craft-service-worker'] = [
            'route' =&gt; 'cachecraft/frontend/cache-craft-service-worker',
            'suffix' =&gt; '.js'
        ];
    }
);


Now I can just access it with https://example.com/cache-craft-service-worker.js which works perfectly fine.