Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

341
Views
Error al obtener la carpeta pública con express en firebase

Tengo este problema cuando intento obtener la carpeta /public con express en firebase.

Mi árbol de proyectos son:

 ProjectRoot ├───functions -> index.js ├───node_modules ├───public -> index.html └───firebase.json

Estoy tratando de obtener /public/index.html de /functions/index.js .

Este es mi index.js

 const functions = require('firebase-functions'); const express = require("express"); var path = require('path'); const app = express(); // Static files app.use("/public", express.static(path.join(__dirname , '/..' , "/public"))); // Routes // Test1 is actually working app.get("/test1", (req, res) => { try{ res.send('🔥Module 1 is on fire🔥'); }catch(error){ console.error("Error Debug: "+ error); } }); // Test2 isn't working app.get("/test2", (req, res) => { try{ res.sendFile('/public/index.html'); }catch(error){ console.error("Error Debug: "+ error); } }); // Test3 isn't working app.get("/test3", (req, res) => { try{ res.sendFile(path.join(__dirname,'/..','/public/index.html')); }catch(error){ console.error("Error Debug: "+ error); } }); exports.app = functions.https.onRequest(app);

La consola me tira cronológicamente

 Function execution took 6 ms, finished with status code: 200 --> Test1 Works ENOENT: no such file or directory, stat '/public/index.html' Test2 code 404 ENOENT: no such file or directory, stat '/public/index.html' Test3 code 404

Y finalmente mi firebase.json son

 { "hosting": { "public": "public", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "function": "app" } ] }, "functions": { "source": "/functions", "runtime": "nodejs16" } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!