Make file available at route Angular 7

Viewed 1464

I'm facing a problem I don't know how to resolve.

I'm trying to integrate my website with Apple Pay using Stripe's PaymentRequest. However, I'm having trouble with one of their requisites. I don't know how to make that file available at the route

https://exampledomain.com/.well-known/apple-developer-merchantid-domain-association 

Can somebody help with this please?

4 Answers

Exact example for OP's question,

Step 1: Create folder in src names .well-known

Step 2: Add apple-developer-merchantid-domain-association file inside .well-known folder

Step 3: Add 2 lines in angular.json assets

"src/.well-known/apple-developer-merchantid-domain-association",
{ "glob": "apple-developer-merchantid-domain-association", "input": "src/.well-known/", "output": "/" },

The final assets will look something like this,

"assets": [
              "src/.well-known/apple-developer-merchantid-domain-association",
              { "glob": "apple-developer-merchantid-domain-association", "input": "src/.well-known/", "output": "/" },
              "src/favicon.ico",
              "src/assets",
              "src/manifest.webmanifest"
            ],

Now, You should be able to access the file on: http://localhost:4200/.well-known/apple-developer-merchantid-domain-association

If you wish to move some static files to build paths you can use angular.json for example:

{
  ...
  "projects": {
    ...
    "#project_name#": {
      ...
      "architect": {
        ...
        "build": {
          ...
          "options": {
            "outputPath": "./build/path/to/project-root/",
            ...
            "assets": [ { "glob": "*", "input": "./src/static", "output": "." },
...

This would move files inside ./src/static folder to build/path/to/project-root/ the output path depends on some build configuration like --output-path and maybe something else.

Solved.

Not using angular. Done it accessing my AWS dashboard and creating there the file. Just in case it helps someone else :)

You can also do it on the hosting directly. In my case, my Angular app is hosted on AWS S3 bucket.

First, create a .well-known folder and upload the file apple-developer-merchantid-domain-association.txt in S3 bucket.

Second, go to Edit Static Website hosting setting. Set the value to .well-known under Index document section.

Related