Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ad Aures
Castopod
Commits
e12f95ac
Unverified
Commit
e12f95ac
authored
Jul 24, 2021
by
Yassine Doghri
Browse files
feat: allow cross origin requests on episode comments
parent
797c96c1
Pipeline
#986
passed with stages
in 9 minutes and 21 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
app/Config/Routes.php
View file @
e12f95ac
...
...
@@ -736,6 +736,7 @@ $routes->group('@(:podcastName)', function ($routes): void {
],
],
]);
$routes
->
options
(
'comments'
,
'EpisodeController::commentsPreflight/$1/$2'
);
$routes
->
get
(
'comments'
,
'EpisodeController::comments/$1/$2'
,
[
'as'
=>
'episode-comments'
,
'application/activity+json'
=>
[
...
...
app/Controllers/EpisodeController.php
View file @
e12f95ac
...
...
@@ -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
());
}
}
Yassine Doghri
@yassine
mentioned in commit
af7d6254
·
Jul 24, 2021
mentioned in commit
af7d6254
mentioned in commit af7d625462ff679d32560ba2f8067680813ce9c1
Toggle commit list
Yassine Doghri
@yassine
mentioned in commit
d807ab97
·
Jan 23, 2022
mentioned in commit
d807ab97
mentioned in commit d807ab9732d8e4ad1eae956f0b728f8a5c0f868d
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment