This migth be silly question but I have very little knowledge of node.js, firebase and devops at overall.
I'm trying to host Uppy Companion app in the Firebase hosting: https://uppy.io/docs/companion/#Options
App works locally, I can deploy it to Firebase but can't access endpoint. I guess the problem is with the config and the host url or some firebase settings I'm not aware of. That's the index.js of app:
const bodyParser = require("body-parser");
const session = require("express-session");
const companion = require("@uppy/companion");
const app = express();
app.use(bodyParser.json());
app.use(
session({
secret: "some-secret",
resave: true,
saveUninitialized: true,
})
);
app.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Origin", req.headers.origin || "*");
next();
});
// Routes
app.get("/companion", (req, res) => {
res.setHeader("Content-Type", "text/plain");
res.send("Welcome to Companion");
});
// initialize uppy
const companionOptions = {
providerOptions: {
drive: {
key: "google drive key",
secret: "google drive secret",
},
},
server: {
host: "localhost:3020",
protocol: "http",
},
filePath: "./output",
secret:"secret",
debug: true,
};
const { app: companionApp } = companion.app(companionOptions);
app.use(companionApp);
// handle 404
app.use((req, res) => {
return res.status(404).json({ message: "Not Found" });
});
// handle server errors
app.use((err, req, res) => {
console.error("\x1b[31m", err.stack, "\x1b[0m");
res.status(err.status || 500).json({ message: err.message, error: err });
});
companion.socket(app.listen(3020));
console.log("Welcome to Companion!");
console.log(`Listening on http://0.0.0.0:${3020}`);
But after deployment when I'm trying access the endpoint I get:
Can someone point me to the direction how to fix this? I guess the problem is with my configuration, not the Firebase itself.
Thanks!