feat: allow cross origin requests on episode comments

This commit is contained in:
Yassine Doghri 2021-07-24 15:33:34 +00:00
commit e12f95aca1
No known key found for this signature in database
GPG key ID: 3E7F89498B960C9F
2 changed files with 15 additions and 0 deletions

View file

@ -210,6 +210,19 @@ class EpisodeController extends BaseController
->setBody($podcastObject->toJSON());
}
/**
* @noRector ReturnTypeDeclarationRector
*/
public function commentsPreflight(): Response
{
return $this->response->setHeader('Access-Control-Allow-Origin', '*') // for allowing any domain, insecure
->setHeader('Access-Control-Allow-Headers', '*') // for allowing any headers, insecure
->setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS') // allows GET and OPTIONS methods only
->setHeader('Access-Control-Max-Age', '86400')
->setHeader('Cache-Control', 'public, max-age=86400')
->setStatusCode(200);
}
/**
* @noRector ReturnTypeDeclarationRector
*/
@ -250,6 +263,7 @@ class EpisodeController extends BaseController
return $this->response
->setContentType('application/activity+json')
->setHeader('Access-Control-Allow-Origin', '*')
->setBody($collection->toJSON());
}
}