mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-10-23 11:38:34 -04:00
Add default API CORS HTTP Headers (#6659)
* Add default API CORS HTTP Headers To allow interacting with our APIs from a JavaScript application. So far limited to the APIs: Greader, User queries Fix https://github.com/FreshRSS/FreshRSS/discussions/6654#discussioncomment-10131144 * Early abort for OPTIONS requests * Move a bit OPTIONS test * No content! * More cleaning
This commit is contained in:
1 parent
5267db88ab
commit
47a3e15edc
2 files changed
+23
No files matched your search
@@ -159,6 +159,15 @@ if ($query->getName() != '') {
|
||||
}
|
||||
FreshRSS_Context::systemConf()->allow_anonymous = true;
|
||||
|
||||
header('Access-Control-Allow-Methods: GET');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Max-Age: 600');
|
||||
header('Cache-Control: public, max-age=60');
|
||||
if (($_SERVER['REQUEST_METHOD'] ?? '') === 'OPTIONS') {
|
||||
header('HTTP/1.1 204 No Content');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (in_array($format, ['rss', 'atom'], true)) {
|
||||
header('Content-Type: application/rss+xml; charset=utf-8');
|
||||
$view->_layout(null);
|
||||
|
||||
Reference in new issue
Block a user