feat: move to Socket.IO

This commit is contained in:
Marco Beretta 2024-12-30 01:47:21 +01:00
parent 9a33292f88
commit c864c366d1
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
9 changed files with 216 additions and 135 deletions

View file

@ -4,15 +4,16 @@ const router = express.Router();
router.get('/', optionalJwtAuth, async (req, res) => {
const isProduction = process.env.NODE_ENV === 'production';
const useSSL = isProduction && process.env.SERVER_DOMAIN?.startsWith('https');
const protocol = useSSL ? 'wss' : 'ws';
const protocol = isProduction && req.secure ? 'https' : 'http';
const serverDomain = process.env.SERVER_DOMAIN
? process.env.SERVER_DOMAIN.replace(/^https?:\/\//, '')
: req.headers.host;
const wsUrl = `${protocol}://${serverDomain}/ws`;
res.json({ url: wsUrl });
const socketIoUrl = `${protocol}://${serverDomain}`;
res.json({ url: socketIoUrl });
});
module.exports = router;