fix http logging spam, and login loop

This commit is contained in:
Isaac 2022-09-07 22:15:46 +01:00
parent be0795cde0
commit 98c6f7a445
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
3 changed files with 14 additions and 4 deletions

View File

@ -4,6 +4,8 @@ https://www.prisma.io/docs/reference/database-reference/supported-databases
menu question max length cannot be higher than question options menu question max length cannot be higher than question options
ports <1024 require root
- TODO: topic and question answer values not encrypted? - TODO: topic and question answer values not encrypted?
- TODO: post stats - TODO: post stats
- TODO: settings bundle download - TODO: settings bundle download

View File

@ -1,5 +1,6 @@
const fastify = require('fastify')(); const fastify = require('fastify')();
const oauth = require('@fastify/oauth2'); const oauth = require('@fastify/oauth2');
const { domain } = require('./lib/http');
const { short } = require('leeks.js'); const { short } = require('leeks.js');
const { join } = require('path'); const { join } = require('path');
const { files } = require('node-dir'); const { files } = require('node-dir');
@ -45,6 +46,12 @@ module.exports = async client => {
fastify.register(require('@fastify/http-proxy'), { fastify.register(require('@fastify/http-proxy'), {
http2: false, http2: false,
prefix: '/settings', prefix: '/settings',
replyOptions: {
rewriteRequestHeaders: (req, headers) => ({
...headers,
'host': domain,
}),
},
rewritePrefix: '/settings', rewritePrefix: '/settings',
upstream: `http://127.0.0.1:${process.env.SETTINGS_BIND}`, upstream: `http://127.0.0.1:${process.env.SETTINGS_BIND}`,
}); });
@ -62,8 +69,6 @@ module.exports = async client => {
}); });
} }
} catch (err) { } catch (err) {
console.log(req);
console.log(req.cookies);
res.send(err); res.send(err);
} }
}); });
@ -126,7 +131,8 @@ module.exports = async client => {
: responseTime >= 5 : responseTime >= 5
? '&e' ? '&e'
: '&a') + responseTime + 'ms'; : '&a') + responseTime + 'ms';
client.log.info.http(short(`${req.id} ${req.ip} ${req.method} ${req.routerPath ?? '*'} &m-+>&r ${status}&b in ${responseTime}`)); const level = req.routerPath.startsWith('/settings') ? 'verbose' : 'info';
client.log[level].http(short(`${req.id} ${req.ip} ${req.method} ${req.routerPath ?? '*'} &m-+>&r ${status}&b in ${responseTime}`));
if (!req.routerPath) client.log.verbose.http(`${req.id} ${req.method} ${req.url}`); if (!req.routerPath) client.log.verbose.http(`${req.id} ${req.method} ${req.url}`);
done(); done();
}); });

View File

@ -23,6 +23,8 @@ module.exports.get = () => ({
sameSite: true, sameSite: true,
secure: false, secure: false,
}) })
.redirect('/settings'); // .redirect('/settings')
.type('text/html')
.send('<a href="/settings">/settings</a>'); // temp fix: redirecting causes weird discord<->callback loop, probably caching?
}, },
}); });