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

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');
        $html2pdf->Output('test'.'.pdf');
    
    }

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

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *