如何在 React App 中使用 Apple 验证我的域

Jor*_*ris 1 reactjs applepay

有人知道如何在 url mydomain.com/.well-known/apple-developer-merchantid-domain-association.txt 上使用 React.js 来验证 Apple 的域吗?

我尝试在公共文件夹中创建 .well-known 文件夹,并将 apple-developer-merchantid-domain-association.txt 文件放入其中。我可以访问该文件(只能访问,不能下载),但 Apple 网站上的验证仍然失败。有人有其他解决方案吗?

我也做了这样的自定义路线

<Route path="/.well-known/apple-developer-merchantid-domain-association.txt" render={() => (
                                    <link rel="apple-developer-merchantid-domain-association.txt file" href="%PUBLIC_URL%/.well-known/apple-developer-merchantid-domain-association.txt" />
                                )}
Run Code Online (Sandbox Code Playgroud)

小智 5

我在使用 Stripe(提供 Apple Pay)托管在 heroku 上的 react 应用程序上做了什么:

  1. 在 ./client :创建一个“applepay”目录并复制/过去“apple-developer-merchantid-domain-association”文件。

1

  1. 在您的客户端 package.json 文件中,找到“脚本”列表,您至少应该在其中阅读"build": "react-scripts build". 添加"mkdir -p ./build/.well-known && cp ./applepay/apple-developer-merchantid-domain-association ./build/.well-known/". 它将在构建过程中创建一个新目录 (mkdir) 并复制 (cp) 在其中的验证文件。
"scripts": {
    ...,
    "build": "react-scripts build && mkdir -p ./build/.well-known && cp ./applepay/apple-developer-merchantid-domain-association ./build/.well-known/",
    ...,
},
Run Code Online (Sandbox Code Playgroud)
  1. 在线推送您更新的代码,确保它是一个 httpS 域,您的 Apple Pay 商户 id 文件应该被检测到。如果您使用 Stripe,您将获得:

2

我希望它有帮助!

  • 不知道为什么这没有被标记为正确答案。对我帮助很大,谢谢! (3认同)