feat: add getBaseUrl function for consistent base URL generation across routes
All checks were successful
Build & Push Docker Image / build (push) Successful in 6m28s
All checks were successful
Build & Push Docker Image / build (push) Successful in 6m28s
feat(calendar): display local timezone in calendar view feat(i18n): add timezone label to German and English translations
This commit is contained in:
@@ -57,3 +57,14 @@ export function generateToken(userId) {
|
||||
const jti = uuidv4();
|
||||
return jwt.sign({ userId, jti }, JWT_SECRET, { expiresIn: '7d' });
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the public base URL for the application.
|
||||
* Prefers APP_URL env var. Falls back to X-Forwarded-Proto + Host header
|
||||
* so that links are correct behind a TLS-terminating reverse proxy.
|
||||
*/
|
||||
export function getBaseUrl(req) {
|
||||
if (process.env.APP_URL) return process.env.APP_URL.replace(/\/+$/, '');
|
||||
const proto = req.get('x-forwarded-proto')?.split(',')[0]?.trim() || req.protocol;
|
||||
return `${proto}://${req.get('host')}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user