2024-12-21 14:36:01 +01:00
|
|
|
const express = require('express');
|
|
|
|
|
const optionalJwtAuth = require('~/server/middleware/optionalJwtAuth');
|
|
|
|
|
const router = express.Router();
|
|
|
|
|
|
|
|
|
|
router.get('/', optionalJwtAuth, async (req, res) => {
|
|
|
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
|
|
|
|
2024-12-30 01:47:21 +01:00
|
|
|
const protocol = isProduction && req.secure ? 'https' : 'http';
|
|
|
|
|
|
2024-12-21 14:36:01 +01:00
|
|
|
const serverDomain = process.env.SERVER_DOMAIN
|
|
|
|
|
? process.env.SERVER_DOMAIN.replace(/^https?:\/\//, '')
|
|
|
|
|
: req.headers.host;
|
|
|
|
|
|
2024-12-30 01:47:21 +01:00
|
|
|
const socketIoUrl = `${protocol}://${serverDomain}`;
|
|
|
|
|
|
|
|
|
|
res.json({ url: socketIoUrl });
|
2024-12-21 14:36:01 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = router;
|