Add cache and CORS headers to ActivityPub endpoints

This commit is contained in:
Hypolite Petovan 2020-04-05 18:02:38 -04:00
parent 1e32f74b0b
commit af817b2ad5
2 changed files with 4 additions and 0 deletions

View File

@ -76,6 +76,8 @@ class Objects extends BaseModule
$data = ['@context' => ActivityPub::CONTEXT];
$data = array_merge($data, $activity['object']);
// Relaxed CORS header for public items
header('Access-Control-Allow-Origin: *');
System::jsonExit($data, 'application/activity+json');
}
}

View File

@ -54,6 +54,8 @@ class Profile extends BaseProfile
// The function returns an empty array when the account is removed, expired or blocked
$data = ActivityPub\Transmitter::getProfile($user['uid']);
if (!empty($data)) {
header('Access-Control-Allow-Origin: *');
header('Cache-Control: max-age=23200, stale-while-revalidate=23200');
System::jsonExit($data, 'application/activity+json');
}
}