riseres
riseres

Reputation: 3182

firebase hosting get ERR_TOO_MANY_REDIRECTS for use dynamic redirect

I am using firebase hosting for SPA (create-react-app) and I want to get params dynamic in the url ex: https://www.exmaple.com/home/:id

I follow the document : https://firebase.google.com/docs/hosting/full-config#section-glob

so I do have code in firebase.json

{
"hosting": {
"public": "build",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"redirects": [
  {
    "source": "/home/:id",
    "type" : 301,
    "destination": "/home/:id"
  }
]
}
}

the result is i get ERR_TOO_MANY_REDIRECT, when I look at debugger tools in network it rediect to the same path.

I have tried, type in 301, 302 or even rewrite property then it got 404 response.

Upvotes: 4

Views: 3147

Answers (1)

abraham
abraham

Reputation: 47893

Your source is "/home/:id" so that requests matching that URL pattern will be redirected. You are then telling it to redirect to "/home/:id". After the redirect happens the request again matches as a request that needs to be redirected so it will be redirected until the browser stops it.

You have to redirect from one place "/home/:id" to a different place "/other/:id".

Upvotes: 3

Related Questions