HotFix for not allowing people to access your module from the outside

This commit is contained in:
Nikola Bjelo committed 2018-11-02 21:31:09 +01:00
1 parent b808f029d3
commit f8adbd534e
2 files changed
+19

No files matched your search

+11
View File
@@ -11,10 +11,21 @@ const mongodbConfig = require('./models/MongoDB')
const checkJwt = require('./auth/middleware/jwt')
const logger = require('./utils/logger')
const wrongPreshared = require('./errors/notAllowed.json')
const cors = require('cors')
const app = express()
// Checking preshared key
app.post('/graphql', (req, res, next) => {
if (req.headers.preshared === process.env.PRESHARED_GATEWAY_KEY) {
next();
} else {
res.send(wrongPreshared);
}
});
// Allow crosss-origin requests
app.use(cors())
+8
View File
@@ -0,0 +1,8 @@
{
"errors": [
{
"code": 401,
"message": "Wait, you're not supposed to be here, go through the gate as everyone else"
}
]
}