I'm having trouble accessing a JSON api that is inside of my Firebase account. I'll type "firebase deploy" in my terminal and it'll return the following url,
If I then enter it into my browser I get my Index.html page so I know it generally works. But being that I'm trying to access the API I search the URL/api/app which works when I run "firebase serve" but doesn't when I run deploy. It returns the following
ERROR: Forbidden Your client does not have permission to get URL /api/app from this server
however my gmail account is permitted on firebase and everything checks out but firebase & cloud functions still won't let me access my API. Please help.
This is my code.
INDEX.JS
const functions = require("firebase-functions");
const server = require(__dirname,"../server.js");
const api = functions
.runWith({ memory: "2GB", timeoutSeconds: 120 })
.https.onRequest(server);
module.exports = {
api
};
SERVER.JS
const express = require("express");
const path = require("path");
const logger = require("./middleware/logger.js");
const cors = require("cors");
const routes = require("./router/routes.js");
let app = express();
// Init Middleware
app.use(logger);
// Set static folder
app.use(express.static(path.join(__dirname, "public")));
app.use(cors({ origin: true }));
app.use("/", routes);
module.exports = app;
FIREBASE.JSON
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "public",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"function": "server"
}
]
}
}