| | |
| | | const path = require("path") |
| | | const fastify = require('fastify')({ |
| | | logger: true |
| | | }) |
| | |
| | | |
| | | ///////////////////////////////////////////////////////////////////////// |
| | | |
| | | fastify.register(require('@fastify/static'), { |
| | | root: path.join(__dirname, 'vue/dist'), |
| | | prefix: '/ui/', // optional: default '/' |
| | | // constraints: { host: 'example.com' } // optional: default {} |
| | | }) |
| | | |
| | | // AUTH |
| | | fastify.addHook("onRequest", async (req, res) => { |
| | | console.log(req.url) |
| | | const token = req.query.token |
| | | if (token !== settings.authtoken) { |
| | | if (token !== settings.authtoken && !req.url.startsWith("/ui/")) { |
| | | console.error("# AUTH ERROR #", token) |
| | | await promiseDelay(500) // delay response to avoid denial of service attacks |
| | | res.code(403) |