test self-hosting
This commit is contained in:
@@ -15,25 +15,43 @@ export async function postEvent(
|
|||||||
) {
|
) {
|
||||||
if (process.env.TEST_SELF_HOSTING) {
|
if (process.env.TEST_SELF_HOSTING) {
|
||||||
try {
|
try {
|
||||||
|
const ip = getClientIp(request)!;
|
||||||
|
const headers: HeadersInit = {
|
||||||
|
origin: request.headers.origin!,
|
||||||
|
'user-agent': request.headers['user-agent']!,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
};
|
||||||
|
|
||||||
|
if (ip) {
|
||||||
|
headers['X-Forwarded-For'] = ip;
|
||||||
|
headers['x-real-ip'] = ip;
|
||||||
|
headers['x-client-ip'] = ip;
|
||||||
|
headers['CF-Connecting-IP'] = ip;
|
||||||
|
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'
|
||||||
|
] 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
|
// Test batching on a different service
|
||||||
await fetch('https://op.coderax.se/api/event', {
|
await fetch('https://op.coderax.se/api/event', {
|
||||||
headers: {
|
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!,
|
|
||||||
'user-agent': request.headers['user-agent']!,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'openpanel-client-id': request.headers[
|
|
||||||
'openpanel-client-id'
|
|
||||||
] as string,
|
|
||||||
'openpanel-client-secret': request.headers[
|
|
||||||
'openpanel-client-secret'
|
|
||||||
] as string,
|
|
||||||
'mixan-client-id': request.headers['mixan-client-id'] as string,
|
|
||||||
'mixan-client-secret': request.headers[
|
|
||||||
'mixan-client-secret'
|
|
||||||
] as string,
|
|
||||||
},
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(request.body),
|
body: JSON.stringify(request.body),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user