mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #619 from omnivore-app/content-fetch-token
Add token verification to the content-fetch service
This commit is contained in:
commit
fa2302971a
1 changed files with 13 additions and 2 deletions
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
const express = require('express');
|
||||
|
||||
const app = express();
|
||||
|
|
@ -8,12 +6,25 @@ const fetchContent = require('./fetch-content');
|
|||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
if (!process.env.VERIFICATION_TOKEN) {
|
||||
throw new Error('VERIFICATION_TOKEN environment variable is not set');
|
||||
}
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
if (req.query.token !== process.env.VERIFICATION_TOKEN) {
|
||||
console.log('query does not include valid token')
|
||||
res.send(403)
|
||||
return
|
||||
}
|
||||
fetchContent(req, res)
|
||||
});
|
||||
|
||||
app.post('/', (req, res) => {
|
||||
if (req.query.token !== process.env.VERIFICATION_TOKEN) {
|
||||
console.log('query does not include valid token')
|
||||
res.send(403)
|
||||
return
|
||||
}
|
||||
fetchContent(req, res)
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue