diff --git a/src/handler.test.ts b/src/handler.test.ts index 370e567..de120e0 100644 --- a/src/handler.test.ts +++ b/src/handler.test.ts @@ -217,7 +217,8 @@ describe('getIndexHandler', () => { assert.strictEqual(jsonMock.mock.calls.length, 1); assert.deepStrictEqual(jsonMock.mock.calls[0].arguments[0], { - message: 'Run this command from your terminal: curl -s http://example.com/ | sh', + message: + "Run this command from your terminal: curl -s http://example.com/ | sh -- -k 'YOUR_OPEN_AI_API_KEY'", }); }); }); diff --git a/src/handler.ts b/src/handler.ts index f1479fa..37f21c1 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -82,7 +82,7 @@ export function getIndexHandler( } if (!req.headers['user-agent']?.includes('curl')) { - const command = `curl -s ${domain}/ | sh`; + const command = `curl -s ${domain}/ | sh -- -k 'YOUR_OPEN_AI_API_KEY'`; if (req.get('Content-Type') === 'application/json') { return res.status(200).json({ message: `${message} ${command}` }); diff --git a/src/middleware.ts b/src/middleware.ts index f2d2b99..461a2c5 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -37,6 +37,10 @@ export function limitIPsMiddleware( const ips = appConfig.IPS.split(', '); return (req: Request, res: Response, next: NextFunction) => { try { + if (req.body?.apiKey && req.body?.apiKey?.length) { + return next(); + } + const ip = getIpAddress(req); if (!ips.includes(ip)) {