HotFix for not allowing people to access your module from the outside
This commit is contained in:
1 parent
b808f029d3
commit
f8adbd534e
2 files changed
+19
No files matched your search
@@ -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())
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"errors": [
|
||||
{
|
||||
"code": 401,
|
||||
"message": "Wait, you're not supposed to be here, go through the gate as everyone else"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user