mirror of
https://git.meshkee.com/Meshkee/backend.git
synced 2026-08-11 22:30:59 +04:30
Support local public invoice URLs with port overrides.
Dev can set INVOICE_PUBLIC_BASE_URL or DEV_PORT/HOST so copied links reach the Vite viewer. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
49a9f0c289
commit
d8f4e8c4e5
@@ -394,17 +394,27 @@ export class InvoicesService {
|
||||
.replace(/^https?:\/\//i, '')
|
||||
.replace(/\/$/, '');
|
||||
|
||||
if (opts?.ownerScope === InvoiceOwnerScope.business) {
|
||||
const host = opts.businessHost ? normalizeHost(opts.businessHost) : '';
|
||||
if (host) {
|
||||
return `https://${host}/invoices/${publicId}`;
|
||||
}
|
||||
}
|
||||
|
||||
// Local / explicit override (includes port), e.g. https://meshkee.app:5174
|
||||
const base = process.env.INVOICE_PUBLIC_BASE_URL?.trim();
|
||||
if (base) {
|
||||
return `${base.replace(/\/$/, '')}/invoices/${publicId}`;
|
||||
}
|
||||
|
||||
if (opts?.ownerScope === InvoiceOwnerScope.business) {
|
||||
const host = opts.businessHost ? normalizeHost(opts.businessHost) : '';
|
||||
if (host) {
|
||||
// Dev-only: append port so links open the local public viewer.
|
||||
const devPort = process.env.INVOICE_PUBLIC_DEV_PORT?.trim();
|
||||
if (process.env.NODE_ENV !== 'production' && devPort) {
|
||||
const protocol =
|
||||
process.env.INVOICE_PUBLIC_DEV_PROTOCOL?.trim() || 'https';
|
||||
const devHost = process.env.INVOICE_PUBLIC_DEV_HOST?.trim() || host;
|
||||
return `${protocol}://${normalizeHost(devHost)}:${devPort}/invoices/${publicId}`;
|
||||
}
|
||||
return `https://${host}/invoices/${publicId}`;
|
||||
}
|
||||
}
|
||||
|
||||
const domain = process.env.INVOICE_PUBLIC_DOMAIN?.trim() || 'meshkee.com';
|
||||
return `https://${domain}/invoices/${publicId}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user