@@ -14,7 +14,7 @@ import { createLogger } from '../../factories/logger-factory'
1414import { escapeHtml , safeJsonForScript } from '../../utils/html'
1515import { fromBech32 , toBech32 } from '../../utils/transform'
1616import { getPublicKey , getRelayPrivateKey } from '../../utils/event'
17- import { getRemoteAddress } from '../../utils/http'
17+ import { getPublicPathPrefix , getRemoteAddress } from '../../utils/http'
1818import { getTemplate } from '../../utils/template-cache'
1919
2020const logger = createLogger ( 'post-invoice-controller' )
@@ -125,6 +125,7 @@ export class PostInvoiceController implements IController {
125125 const relayPubkey = getPublicKey ( relayPrivkey )
126126
127127 const expiresAt = invoice . expiresAt ?. toISOString ( ) ?? ''
128+ const pathPrefix = getPublicPathPrefix ( request , currentSettings )
128129
129130 const pageContent = getTemplate ( './resources/post-invoice.html' )
130131 const body = pageContent
@@ -133,6 +134,7 @@ export class PostInvoiceController implements IController {
133134 . replaceAll ( '{{relay_url_html}}' , escapeHtml ( relayUrl ) )
134135 . replaceAll ( '{{invoice_html}}' , escapeHtml ( invoice . bolt11 ) )
135136 . replaceAll ( '{{pubkey_html}}' , escapeHtml ( pubkey ) )
137+ . replaceAll ( '{{path_prefix}}' , escapeHtml ( pathPrefix ) )
136138 . replaceAll ( '{{amount}}' , ( amount / 1000n ) . toString ( ) )
137139 // JS contexts — safeJsonForScript serializes and escapes < to prevent </script> injection
138140 . replaceAll ( '{{reference_json}}' , safeJsonForScript ( invoice . id ) )
@@ -141,6 +143,7 @@ export class PostInvoiceController implements IController {
141143 . replaceAll ( '{{invoice_json}}' , safeJsonForScript ( invoice . bolt11 ) )
142144 . replaceAll ( '{{pubkey_json}}' , safeJsonForScript ( pubkey ) )
143145 . replaceAll ( '{{expires_at_json}}' , safeJsonForScript ( expiresAt ) )
146+ . replaceAll ( '{{path_prefix_json}}' , safeJsonForScript ( pathPrefix ) )
144147 . replaceAll ( '{{processor_json}}' , safeJsonForScript ( currentSettings . payments . processor ) )
145148 // nonce is crypto-random base64 — safe in both attribute and script contexts
146149 . replaceAll ( '{{nonce}}' , response . locals . nonce )
0 commit comments