We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Cross Domain Access

I need to allow cross domain aceess. I found some discusstion on allowing those in micro platform but my one is not micro and need to know how can I allow that. Can anyone please help me?

If you want people to be able to reach your webapp from external domains you'll need to send the Access-Control-Allow-Origin header. In Phalcon you could do that like this:

class SomeController extends ControllerBase
{
    public function crossDomainAction()
    {
        // If you want literally anyone to be able to access your endpoint:
        $this->response->setHeader("Access-Control-Allow-Origin", "*");

        // If you want only specific domains to be able to access your domain:
        // In this example you can only reach your website from `https://www.example.com`
        $this->response->setHeader("Access-Control-Allow-Origin", "https://www.example.com");
    }
}

If you want to do this globally over your entire application (not recommended, check out HTTP access control (CORS) for more info):

class ControllerBase extends Controller
{
    public function afterExecuteRoute()
    {
        $this->response->setHeader("Access-Control-Allow-Origin", "*");
    }
}