Skip to content

Instantly share code, notes, and snippets.

@hiranya911
Created August 4, 2021 23:08
Show Gist options
  • Save hiranya911/989f659e76da89357ed0e8b0f045b330 to your computer and use it in GitHub Desktop.
Save hiranya911/989f659e76da89357ed0e8b0f045b330 to your computer and use it in GitHub Desktop.
const express = require('express');
const admin = require('firebase-admin');
const app = express();
admin.initializeApp();
const appCheckVerification = async (req, res, next) => {
const appCheckToken = req.header('X-Firebase-AppCheck');
if (!appCheckToken) {
res.status(401);
return next('Unauthorized');
}
try {
await admin.appCheck().verifyToken(appCheckToken);
return next();
} catch (err) {
res.status(401);
return next('Unauthorized');
}
}
app.get('/quote', [appCheckVerification], async (req, res) => {
const data = await callExternalService();
res.json(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment