Home > other >  Specified "public" directory {path} does not exist
Specified "public" directory {path} does not exist

Time:09-16

I am trying to add Hosting to an existing firebase app that has Functions up and running. I intended to host a react app that consume my existing functions. The public directory I chose for hosting is /{react-project-root-folder}/build.

I followed enter image description here

firebase.json:

{
  "functions": {
    "ignore": [
      "node_modules",
      ".git",
      "firebase-debug.log",
      "firebase-debug.*.log"
    ],
    "source": "functions"
  },
  "hosting": {
    "public": "/view/build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/api/*",
        "function": "api"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

CodePudding user response:

Turn out you do not need the first / on your public path.

Corrected firebase.json:

{
  "functions": {
    "ignore": [
      "node_modules",
      ".git",
      "firebase-debug.log",
      "firebase-debug.*.log"
    ],
    "source": "functions"
  },
  "hosting": {
    "public": "view/build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

  • Related