M
M
mevec750702020-01-12 10:27:07
Node.js
mevec75070, 2020-01-12 10:27:07

How to make permission to open pages for user-agent on Node js?

I have an application to serve static html files to node js using express

app.get("/app/:type", async(req, res) => {
    if (!req.query.host || !req.query.key) return res.end("error");

    if (["1", "2", "3"].indexOf(req.params.type) === -1) res.end(":)")

    if (!fs.existsSync("./appfile/" + req.params.type + ".txt")) res.end("error")

    var file = await readFile("./appfile/" + req.params.type + ".txt");

    res.end(file);
  });

How can I make sure that only the user agents I specified have access to these files?
Suppose I am making a script for parsing my files, and I must specify exactly the agent that I have above in the script, and the one who does not know which one to insert cannot access the pages above.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question