You can do this using Firebase Functions, and an Express call. Put all of your static files into a folder named functions/admin
and put this function into functions/index.js
:
exports.admin = functions.https.onRequest((req, res) => {
const url = req.originalUrl ? req.originalUrl : '/index.html' // default to index.html
res.sendfile('admin' + url)
})
Then, a request to your functions server for /admin/*
will serve up the file of the same name.
If you want to add authorization, try this:
exports.admin = functions.https.onRequest(async (req, res) => {
const url = req.originalUrl ? req.originalUrl : '/index.html'
const user = await get_user(req) // get the current user
if (user && user.is_admin) // is current user an admin?
res.sendfile('admin' + url)
else {
res.status(403).send(null)
}
})
You will have to define get_user()
so it returns a user object with an is_admin
field.