test self-hosting

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-07-02 22:36:32 +02:00
parent b68e149363
commit 42ede249ea

View File

@@ -15,25 +15,43 @@ export async function postEvent(
) { ) {
if (process.env.TEST_SELF_HOSTING) { if (process.env.TEST_SELF_HOSTING) {
try { try {
// Test batching on a different service const ip = getClientIp(request)!;
await fetch('https://op.coderax.se/api/event', { const headers: HeadersInit = {
headers: {
['X-Forwarded-For']: request.headers['X-Forwarded-For'] as string,
['x-real-ip']: request.headers['x-real-ip'] as string,
origin: request.headers.origin!, origin: request.headers.origin!,
'user-agent': request.headers['user-agent']!, 'user-agent': request.headers['user-agent']!,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'openpanel-client-id': request.headers[ };
'openpanel-client-id'
] as string, if (ip) {
'openpanel-client-secret': request.headers[ headers['X-Forwarded-For'] = ip;
'openpanel-client-secret' headers['x-real-ip'] = ip;
] as string, headers['x-client-ip'] = ip;
'mixan-client-id': request.headers['mixan-client-id'] as string, headers['CF-Connecting-IP'] = ip;
'mixan-client-secret': request.headers[ headers.Forwarded = 'for=' + ip;
}
if (request.headers['mixan-client-id']) {
headers['openpanel-client-id'] = request.headers[
'mixan-client-id'
] as string;
if (request.headers['mixan-client-secret']) {
headers['openpanel-client-secret'] = request.headers[
'mixan-client-secret' 'mixan-client-secret'
] as string, ] as string;
}, }
} else if (request.headers['openpanel-client-id']) {
headers['openpanel-client-id'] = request.headers[
'openpanel-client-id'
] as string;
if (request.headers['openpanel-client-secret']) {
headers['openpanel-client-secret'] = request.headers[
'openpanel-client-secret'
] as string;
}
}
// Test batching on a different service
await fetch('https://op.coderax.se/api/event', {
headers,
method: 'POST', method: 'POST',
body: JSON.stringify(request.body), body: JSON.stringify(request.body),
}) })