简体   繁体   English

如何阅读 Vapor 4 上的 apple-app-site-association 文件?

[英]How to read the apple-app-site-association file on Vapor 4?

For the auto-fill password to work on the Apple platforms, I am testing out Apple App Site Association (AASA) Validator in this website .为了让自动填充密码在 Apple 平台上工作,我正在这个网站上测试Apple App Site Association (AASA) Validator I have added the required json in the Public/.well-known/apple-app-site-association file for the auto-fill password to work on my iOS application.我已经在Public/.well-known/apple-app-site-association文件中添加了所需的 json,以便自动填充密码在我的 iOS 应用程序上工作。

The result from this test comes back with this error: Your file's 'content-type' header was not found or was not recognized .此测试的结果返回此错误: Your file's 'content-type' header was not found or was not recognized

Does anyone have ever encounter this issue?有没有人遇到过这个问题? It seems that the AASA file is not being downloading into my device.似乎 AASA 文件没有下载到我的设备中。

Note that on iOS 14, AASA files will be delivered via Apple's CDN, which is different from how AASA files are currently downloaded.请注意,在 iOS 14 上,AASA 文件将通过 Apple 的 CDN 交付,这与当前下载 AASA 文件的方式不同。

Is there something else to do about it on my Vapor 4 project to make things work?在我的 Vapor 4 项目中还有其他事情要做吗? 在此处输入图像描述

I meat the same issue, follow by imike's answer and doing some research, here is the solution.我遇到了同样的问题,请按照 imike 的回答并进行一些研究,这就是解决方案。

  1. create a custom Middleware创建自定义中间件
struct UniversalLinksMiddleware: Middleware {
    
    func respond(to request: Request, chainingTo next: Responder) -> EventLoopFuture<Response> {
        guard request.url.string == "/.well-known/apple-app-site-association" else {
            return next.respond(to: request)
        }
        
        return next.respond(to: request).map { response in
            response.headers.add(name: "content-type", value: "application/json")
            return response
        }
    }
    
}

  1. add this middleware at config.swift file.config.swift文件中添加此中间件。 Be aware of the order you add middleware, you must add it before FileMIddleware .注意添加中间件的顺序,必须在FileMIddleware之前添加。 Because the responses leaving your application goes through the middleware in reverse order.因为离开您的应用程序的响应以相反的顺序通过中间件。
app.middleware.use(UniversalLinksMiddleware())
app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Vapor 4 中设置 Content-Type 响应 header? - How to set the Content-Type response header in Vapor 4? 在 Vapor 4 中注册新用户时如何保护我的路线? - How can I protect my routes when signing up a new user in Vapor 4? 如何从SharePoint场中的网站集中获取所有ContentTypes - How to get all ContentTypes from a Site Collection in a SharePoint Farm SharePoint 2007:如何跨站点查找值? - SharePoint 2007: How to cross-site lookup value? 在Android上从浏览器下载具有特定内容类型的文件时,如何打开我的应用程序? - How to open my app when I download a file with specific content-type from the browser, on android? 尝试阅读多部分邮件/签名邮件时,原始附件将被忽略,仅显示smime.7ps文件 - While trying to read a multipart/signed mail, the original attachments are ignored and only smime.7ps file is displayed 在操作系统之间注册自定义协议或MIME关联是否更容易? - Is it easier to register a custom protocol or a MIME-association across OSes? 尝试从应用程序内下载.apk文件。 出现“客户端标识头”错误 - Trying to download .apk file from within app. Getting “client identification header” error 如何在IE9中使用文件上传器获取文件contentType - How to get file contentType using file uploader in IE9 Google App Engine如何修改HTTP请求/响应编码? - How does Google App Engine modify HTTP request/response encoding?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM