16

Im working on universal link to open the application while tap the url. I am using https server and done all the steps from apple (Apple Doc). But the apple universal link validator show below error,

Your file's 'content-type' header was not found or was not recognized.

enter image description here

The apple-app-site-association file successfully uploaded to server and the file be like below,

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "J2HBF9A3PZ.com.aors.speaku",
                "paths": ["*","/"]
            }
        ]   
    }
}

And apple said no need to sign the apple-app-site-association file whether the domain has https.

If the file is unsigned, it should have a Content-Type of application/json. Otherwise, it should be application/pkcs7-mime.

So my query is how to mention the content type (application/json) in this apple-app-site-association file???

please help me on this. i don't know what it mean exactly.

Rob
  • 415,655
  • 72
  • 787
  • 1,044
Karthik Saminathan
  • 161
  • 1
  • 1
  • 5

4 Answers4

50

I just solved this issue myself. I had to logon to my server and go to the directory where the apple-app-site-association file was. In this directory, I had a .htaccess file which I modified to include the following lines:

<Files "apple-app-site-association">
ForceType 'application/json'
</Files>

After doing this, the validation service stopped complaining about the Content-Type.

NOTES:

  • If you don't have a .htaccess file, you can just create one.
  • I presume the .htaccess file should be in the root of your site directory (which is where you would most likely have placed your apple-app-site-association file.
Hodson
  • 3,438
  • 1
  • 23
  • 51
  • 1
    That was clever :) – Rameez Rami Jun 26 '18 at 04:55
  • 1
    I have followed the above steps, still stuck. When I validate on branch/io, it is giving me errors. - Your server returned an error status code (>= 400). This includes client side and server side errors. Want to know what this means? Click here. - Content type test did not run. Be sure to define a ‘content-type’ header. - JSON test did not run. Your file should contain valid JSON. – Rajesh Nov 16 '18 at 12:35
  • 1
    Now I receive these errors - Your file's 'content-type' header was not found or was not recognized. - JSON test did not run. Your file should contain valid JSON. – Rajesh Nov 16 '18 at 13:26
  • 1
    I have the same problem. can't resolve the content-type problem – Mahdi Shabani Jan 05 '19 at 15:22
  • Same issues... I dont know whats the problem. I added your .htaccess but got : Your server returned an error status code (>= 400). This includes client side and server side errors. Want to know what this means? Click here. Learn More Content type test did not run. Be sure to define a ‘content-type’ header. JSON test did not run. Your file should contain valid JSON. – Julien Levallois Jul 05 '19 at 21:22
  • If anyone else comes upon this... I tried lots of solutions and this one didn't work for me either... the only one that did was adding this to my .htaccess: `RewriteRule ^apple-app-site-association$ - [env=apple:1] Header set Content-type application/json env=apple` – Britton Pentakill Sep 22 '19 at 18:30
  • best solution , I spent 6 hours on why domain has validation issue – Dharini Jan 22 '20 at 10:24
2

This one fixed the content type validation in firebase.json file.

 {
  "hosting": {
    "public": "public",
    "headers": [
      {
        "source": "/.well-known/apple-app-site-association",
        "headers": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ]
      }
    ],
    "appAssociation": "NONE"
  }
}
Mazen Kasser
  • 3,559
  • 2
  • 25
  • 35
1

Wordpress website. Pasting this at the end of .htaccess actually worked for me:

Header set Content-type "application/pkcs7-mime"

Ophir Stern
  • 1,277
  • 12
  • 22
0

This syntax is what worked for me:

<FilesMatch "apple-app-site-association">
    ForceType application/json
</FilesMatch>
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 04 '22 at 05:21