We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Enable Cross Origin Resource Sharing using Micro

I'm trying to access an api using ajax from an iframe. my ajax call looks like this

var formSubmit = $.ajax({ url: url, type: 'POST', data: pm, beforeSend: function () { $('input:submit').attr("disabled", true); } })

how do I set 'Access-Control-Allow-Origin' header to fix the "No 'Access-Control-Allow-Origin' header is present on the requested resource" error. I'm using Micro in phalcon, not Application

Thanks

In apache/nginx configuration



7.9k
edited Feb '16

you can use $app->after to create cors response header before send it to client