Created
August 4, 2021 23:08
-
-
Save hiranya911/989f659e76da89357ed0e8b0f045b330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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