Skip to content

Commit

Permalink
simple authorization check
Browse files Browse the repository at this point in the history
  • Loading branch information
lohanidamodar committed Aug 4, 2023
1 parent 47dd438 commit 1a80d4a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ reference docs. For each question show code examples when applicable.
${prompt}`;

app.post("/", async (req, res) => {
const secret = req.headers.authorization;
if(secret !== process.env.ASSISTANT_SECRET) {
res.status(403);
res.send('Unauthorized access. Please make sure you are providing the authorized secret key.')
return;
}
// raw to text
const decoder = new TextDecoder();
const text = decoder.decode(req.body);
Expand All @@ -37,5 +43,5 @@ app.post("/", async (req, res) => {
});

app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
console.log(`Started server on port: ${port}`);
});

0 comments on commit 1a80d4a

Please sign in to comment.