diff --git a/src/config/config.ts b/src/config/config.ts index a04b0b52..2aa15754 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -187,6 +187,10 @@ export class Configuration { apiUrl: process.env.SWAP_API_URL, }; + boltzClaim = { + apiUrl: process.env.BOLTZ_CLAIM_API_URL, + }; + // --- GETTERS --- // get baseUrl(): string { return this.environment === Environment.LOC diff --git a/src/main.ts b/src/main.ts index b22ac0f5..2ff72bdb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -60,6 +60,25 @@ async function bootstrap() { server.on('upgrade', forwardProxy.upgrade); } + // --- REWRITE BOLTZ CLAIM URL --- // + if (Config.boltzClaim.apiUrl) { + const rewriteUrl = `/${Config.version}/claim`; + const forwardProxy = createProxyMiddleware({ + target: Config.boltzClaim.apiUrl, + changeOrigin: true, + toProxy: true, + secure: false, + pathRewrite: { [rewriteUrl]: '' }, + on: { + proxyReq(proxyReq, req: Request) { + if (req.ip) proxyReq.setHeader('X-Forwarded-For', req.ip.split(':')[0]); + fixRequestBody(proxyReq, req); + }, + }, + }); + app.use(rewriteUrl, forwardProxy); + } + // --- SWAGGER --- // const swaggerOptions = new DocumentBuilder() .setTitle('lightning.space API')