Error by CORS policy creating PDF with html2PDF with symfony [duplicate]

  angular, html2pdf, php, symfony

I am creating a website with symfony and angular. I would like to export a PDF with Html2PDF.

But I get an error:

Access to XMLHttpRequest at ‘http://localhost/pdf’ from origin ‘http://localhost:4200’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.**

here is my code

  public function index(): string

        $html2pdf = new Html2Pdf('P', 'A4', 'fr');

However when I access by the link: localhost/80/pdf it works. well
Any ideas ?

Source: Symfony Questions