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
+5
-1
@@ -94,5 +94,9 @@ SSL_SYNC_AGENT_TOKEN=
|
|||||||
|
|
||||||
# Public domain for platform invoice links (https://{domain}/invoices/{id})
|
# Public domain for platform invoice links (https://{domain}/invoices/{id})
|
||||||
INVOICE_PUBLIC_DOMAIN=meshkee.com
|
INVOICE_PUBLIC_DOMAIN=meshkee.com
|
||||||
# Optional full origin for local (overrides domain), e.g. https://meshkee.app:5174
|
# Optional full origin for local (overrides domain + business host), e.g. https://meshkee.app:5174
|
||||||
# INVOICE_PUBLIC_BASE_URL=https://meshkee.app:5174
|
# INVOICE_PUBLIC_BASE_URL=https://meshkee.app:5174
|
||||||
|
# Or keep production-style hosts and only append a port in non-production:
|
||||||
|
# INVOICE_PUBLIC_DEV_PORT=5174
|
||||||
|
# INVOICE_PUBLIC_DEV_HOST=meshkee.app
|
||||||
|
# INVOICE_PUBLIC_DEV_PROTOCOL=https
|
||||||
|
|||||||
@@ -394,17 +394,27 @@ export class InvoicesService {
|
|||||||
.replace(/^https?:\/\//i, '')
|
.replace(/^https?:\/\//i, '')
|
||||||
.replace(/\/$/, '');
|
.replace(/\/$/, '');
|
||||||
|
|
||||||
if (opts?.ownerScope === InvoiceOwnerScope.business) {
|
// Local / explicit override (includes port), e.g. https://meshkee.app:5174
|
||||||
const host = opts.businessHost ? normalizeHost(opts.businessHost) : '';
|
|
||||||
if (host) {
|
|
||||||
return `https://${host}/invoices/${publicId}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const base = process.env.INVOICE_PUBLIC_BASE_URL?.trim();
|
const base = process.env.INVOICE_PUBLIC_BASE_URL?.trim();
|
||||||
if (base) {
|
if (base) {
|
||||||
return `${base.replace(/\/$/, '')}/invoices/${publicId}`;
|
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';
|
const domain = process.env.INVOICE_PUBLIC_DOMAIN?.trim() || 'meshkee.com';
|
||||||
return `https://${domain}/invoices/${publicId}`;
|
return `https://${domain}/invoices/${publicId}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user