powerman / perl-Mojolicious-Plugin-SecureCORS

Perl module: Mojolicious::Plugin::SecureCORS - Complete control over CORS
https://metacpan.org/release/Mojolicious-Plugin-SecureCORS
Other
0 stars 4 forks source link

after_render doesn't work for render_later #5

Open PavelTrushkin opened 5 years ago

PavelTrushkin commented 5 years ago

i read another closed issue for after_render but anyway:

Mojolicious::Controller doesn't call after_render if you render content dynamically and use render_later/write_chunk

may be better to use

$app->hook(around_action => \&_request);

and check $last hook argument in _request

powerman commented 5 years ago

Can you please explain issue you're trying to solve this way?

PavelTrushkin commented 5 years ago

I have controller which dynamically generates content using $c->write_chunk and $c->render_later, in this case Mojolicious does not call after_render hook and calling application (browser) does not see Access-Control-Allow-Origin and other headers set by Mojolicious::Plugin::SecureCORS::_request

around_action is definitely better in this case, i tested it works but i am not sure for 100%

powerman commented 5 years ago

I see, it makes sense. Well, PR is welcome - I don't think I'll have time to implement this anytime soon. (PR should include test for your use case.)