Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
Firebase cloud functions CAN'T find static files in public folder
  • project
    • stripejs
      • functions
        • index.js

        • public

          • success.html

It's been hours I'm trying to redirect an API ( using cloud functions) to my html page (inside the public folder).

router.get('/finishOnboarding',  async (req,res) => {

    let content =  path.resolve('../public/success.html')
    res.sendFile(content);

});

I tried multiples things.

  1. put the public folder Outside of the functions folder, then i noticed i need to nest it inside because when deploying it need to be accessed in google cloud

  2. using __dirname + absolute path

No matters what I do, When I'm checking the Functions logs I always got the same error :

Error: ENOENT: no such file or directory, stat '/public/success.html'

If I'm trying to redirect using

path.join(__dirname, '/public/success.html');

I got :

Error: ENOENT: no such file or directory, stat '/workspace/routes/public/success.html'

firebase.json is configured as needed

{
  "hosting": {
    "public": "functions/public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "function": "app"
      }
    ]  
  },
  "emulators": {
    "hosting": {
      "port": 5003
    }
  }
}

Where is the problem coming from? I'm sure its a simple problem with the paths, but Im very confused..

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Cloud Functions and Hosting run on completely separate infrastructure, so you can't reach from one to the other with a path type call.

If you want to redirect the user, you'll need to send a redirect instruction on the response. Doing that means the browser will get the instruction to request a different URL, and that request will then be served by Firebase Hosting.

If you want to rewrite the response (so serve HTML from a different location within your code), you will need to have those files inside (or under) the functions folder:

  • project
    • stripejs
      • functions
        • index.js

        • public

          • success.html
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda