如何使用 Laravel Vapor 发布清单文件

问题描述

我想在 Laravel Vapor 上发布文件 manifest.webmanifest。我尝试在根域 (docs) 上提供它:

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

Vapor 处理该路由,但抛出异常:

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

经过进一步检查,这是合乎逻辑的,因为文件永远不会发送到 S3 存储桶。 Laravel/VaporCli/AssetFiles 似乎过滤了 *.webmanifestmanifest.jsonmix-manifest.json文件

不知道为什么会这样。有没有人有完成工作的技巧?


更新:

一位开发 Vapor replied 的开发人员表示,现在无法对其进行更改,因为这将是一个重大更改。他建议添加一个返回清单内容的路由。

我已将此路线添加到我的项目中:

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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)