Search code examples
phplaravellaravel-vapor

How to publish a manifest file with Laravel Vapor


I would like to publish the file manifest.webmanifest on Laravel Vapor. I've tried to serve it on the root domain (docs):

# vapor.php
...
    'serve_assets' => ['manifest.webmanifest'],
...

Vapor handles that route, but throws an exception:

Client error: `GET https://xxxx.cloudfront.net/xxx/manifest.webmanifest` resulted in a `404 Not Found` response:

After further inspection this is logical, because the file is never send to the S3 bucket. It appears that Laravel/VaporCli/AssetFiles filters files like *.webmanifest, manifest.json and mix-manifest.json.

No clue why it does that. Does anyone have a trick to get the job done?


Solution

  • A developer working on Vapor replied and said changing it isn't possible right now because it will be a breaking change. He suggests adding a route that returns the content of the manifest.

    I've added this route to my project:

    Route::middleware('cache.headers:public;max_age=7200')->get(
        '/manifest.webmanifest',
        function (): string {
            return file_get_contents(public_path('manifest.webmanifest'));
        }
    )