404 on directly hitting page url. browser build

404 on directly hitting page url

After successful upload of the browser build on firebase hosting, I am facing a strange issue.

If i directly hit this (or any) url https://allyot.web.app/brochure, It is showing 404

But https://allyot.web.app/ is working fine, and it also redirects to https://allyot.web.app/brochure only.

Your rewrite rules may be off

Plse post your firebase.json?

ionic build --prod
firebase deploy --only hosting:allyot

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ]
  },
  "hosting": {
    "public": "www",
    "site": "allyot",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "**",
        "destination": "/www/index.html"
      }
    ]
  },
  "storage": {
    "rules": "storage.rules"
  },
  "emulators": {
    "auth": {
      "port": 9099
    },
    "functions": {
      "port": 5001
    },
    "firestore": {
      "port": 8080
    },
    "hosting": {
      "port": 5000
    },
    "pubsub": {
      "port": 8085
    },
    "ui": {
      "enabled": true
    }
  },
  "remoteconfig": {
    "template": "remoteconfig.template.json"
  }
}

"hosting": {
    "public": "www",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },

This is mine.
See the difference in destination? The destination directory is local to the server and the assets are with your rules taken from the local PC folder www, but not placed by default also in a www folder on the server. Basically at firebase init time (or manual changes) you have incorrectly added www to the parameters for the rewrite destination. Maybe try with the www removed?

Thank you, Thanks a lot :partying_face:

1 Like