9

Let's say I have a domain example.com. And I created a second website through hosting and cli as sub.example.com.

{
  "hosting": [
    {
      "target": "app",
      "public": "public",
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    },
    {
      "target": "promos",
      "public": "public",
      "appAssociation": "AUTO",
      "rewrites": [
        {
          "source": "**",
          "dynamicLinks": true
        }
      ]
    }
  ]
}

Now when I go to create Dynamic Link for sub.example.com without any path prefix, it gives me a red flag saying:

It looks like you already have content served on this path. Specify a different path prefix to avoid conflicts with existing content.
  1. What am I doing wrong?
  2. Also, if this subdomain is only for links, I still have to put public field? I don't want to show anything on it, just links...
cocacrave
  • 2,453
  • 4
  • 18
  • 30

2 Answers2

15

I fixed it by adding (or rather ignoring) the public folder for the dynamic links subdomain.

"ignore": [
    "*"
  ],

I saw this post: https://github.com/firebase/firebase-tools/issues/566 and someone asked similar question for functions and the answer was to delete dist/index.html. But since my actual site depends on it, I tried just ignoring it and it seems to work.

cocacrave
  • 2,453
  • 4
  • 18
  • 30
  • This sounds pretty weird. the "ignore" clause just prevents certain local files from being uploaded at deployment. You just need to put the rewrite rule with "dynamicLinks" before the other (more general) rules. – Jaromír Adamec Apr 01 '21 at 14:53
  • This answer saved my day ! Thanks brother – afifi Oct 13 '22 at 17:47
6

I fixed the same issue with @cocacrave's answer. Just sharing the full firebase.json file. * There should be a public folder and settings but my public folder is empty.

{
  "hosting": {
    "public": "public",
    "ignore": [
      "*"
    ],
    "appAssociation": "AUTO",
    "rewrites": [
      {
        "source": "/**",
        "dynamicLinks": true
      }
    ]
  }
}
fatihyildizhan
  • 8,614
  • 7
  • 64
  • 88