【发布时间】:2021-06-02 22:42:35
【问题描述】:
为了在 Apple 平台上使用自动填充密码,我正在这个 website 中测试 Apple App Site Association (AASA) Validator。
我在 Public/.well-known/apple-app-site-association 文件中添加了所需的 json,以便自动填充密码在我的 iOS 应用程序上工作。
此测试的结果返回此错误:
Your file's 'content-type' header was not found or was not recognized.
有人遇到过这个问题吗? AASA 文件似乎没有下载到我的设备中。
请注意,在 iOS 14 上,AASA 文件将通过 Apple 的 CDN 传送,这与当前下载 AASA 文件的方式不同。
【问题讨论】:
-
你的 Vapor 应用前面有 nginx 吗?
-
如果是,那么您可以在虚拟主机文件
location /.well-known/apple-app-site-association { default_type application/json; }中声明正确的内容类型,如果不是,那么您应该在vapor 中创建中间件,该中间件将使用正确的apple-app-site-association流式传输content-type标头跨度> -
我没有使用 nginx。我的 Vapor 应用程序部署在 Heroku 上。你能告诉我如何创建这个特定的中间件吗?
-
只需查看
FileMiddleware来源并对其进行编辑。同样在heroku上,您似乎正在使用FileMiddleware,这对生产不利,因为每个请求(甚至对API端点)它首先检查磁盘上的文件,然后才将请求传递给下一个响应者(路由器),这非常慢用于生产。如果您将使用自己的中间件,请注意这方面,请检查 headers 或 url.lastPathComponent 以了解您必须在磁盘上查找文件,如果没有,则立即传递给下一个响应者。 -
Public文件夹在 Heroku 上运行良好,唯一的问题是apple-app-site-association没有.json扩展名,这就是为什么 FileMiddleware 甚至 nginx 都无法提供正确的content-type标头,所以你必须在自定义中间件中自己完成。
标签: content-type vapor aasa apple-app-site-association