question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

apple-app-site-association static file is triggering dynamic routing

See original GitHub issue

Bug report

Describe the bug

In our /public folder we have a file called apple-app-site-association that is used for deep linking with iOS, etc.

We also have a dynamic route setup that looks like this /[slug]/[id]

When on an iOS device safari looks for this static file apple-app-site-association but for some reason it’s still triggering Next.js routing. This is then causing the slug to be apple-app-site-association and trying to then make an API call with that filename value as the string.

We’ve recently upgraded to the latest version of Next.js and it has only recently happened since upgrading.

To Reproduce

Place an apple-app-site-association file at /public, create a dynamic route like /[slug]/[id] watch for apple-app-site-association to show up in getInitialProps context.

Expected behavior

This file should be ignored within the routing scope like it was previously.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

7reactions
tinaciouscommented, Feb 6, 2021

I had this issue too. I was able to solve this on Vercel with 2 steps:

  1. First, putting the file in ./well-known instead of at the root.
  2. Second, adding a headers entry to my vercel.json file that specifies the header Content-Type: application/json.
{
  "headers": [{
    "source": "/.well-known/apple-app-site-association",
    "headers": [{
      "key": "Content-Type",
      "value": "application/json"
    }]
  }]
}

With these 2 things together I was able to resolve the 308 Permanent redirect issue and avoid having the file download to my machine.

Apple will be fine with the file downloading to your machine though, it’s just not ideal when you’re testing it.

1reaction
pjindal91commented, Sep 24, 2021

I had this issue too. I was able to solve this on Vercel with 2 steps:

  1. First, putting the file in ./well-known instead of at the root.
  2. Second, adding a headers entry to my vercel.json file that specifies the header Content-Type: application/json.
{
  "headers": [{
    "source": "/.well-known/apple-app-site-association",
    "headers": [{
      "key": "Content-Type",
      "value": "application/json"
    }]
  }]
}

With these 2 things together I was able to resolve the 308 Permanent redirect issue and avoid having the file download to my machine.

Apple will be fine with the file downloading to your machine though, it’s just not ideal when you’re testing it.

Is there some pre-req for this solution. It doesn’t seem to be working for me. Still getting content-type as application/octet-stream.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to serve apple-app-site-association file ... - Stack Overflow
You can serve the file using React Router. Put this in your index.js or App.js: ... in my /static folder I put my...
Read more >
Universal Links - SWCERR00305 - de… - Apple Developer
I have an App which should be opened by the associated domain. I think on the xcode-side I did everything right as I...
Read more >
Everything a developer needs to know about deep linking
When a new user on iOS installs the app, the AASA file is downloaded into local storage on the user's device, and is...
Read more >
Configure Hosting behavior | Firebase Hosting - Google
json and apple-app-site-association files when they're requested. rewrites. source. A path that you want to use for Dynamic Links. Unlike rules that rewrite ......
Read more >
Firebase Dynamic Links on iOS: Tutorial | Geniusee
Association file. Use HTTPS from your website's .well-known directory to serve the Apple app site association file you created. Alternate Mode.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found