title: Angular 7 & Laravel
body: <p>I have face some problem while implementing ng2-pdf-viewer.</p>
  
  <p>Ts file:</p>
  
  <p>book-pdf-viewe.component.ts</p>
  
  <pre><code>import { Component, OnInit, Inject, ViewChild } from '@angular/core';
  import { MAT_DIALOG_DATA } from '@angular/material';
  import { fileUpload } from '../commonUrl'; import { BookService } from'../book.service';
  
  @Component({  
        selector: 'app-book-pdf-viewe',   
        templateUrl: './book-pdf-viewe.component.html',  
        styleUrls: ['./book-pdf-viewe.component.css'] 
       })
  
  export class BookPdfVieweComponent implements OnInit {
  
         urlofFile = fileUpload;   
         pdfSrc: string;
  
         constructor(
          @Inject(MAT_DIALOG_DATA) public data: any,
          public bookService:BookService,   ) {
  
          console.log(data.filename,data.book_id);
          this.bookService.getSpecificbook(data.book_id).subscribe( bookData =&gt; {
            console.log('first',bookData[0].file);
            this.pdfSrc = this.urlofFile+'uploads/books/'+bookData[0].file;
             console.log("2nd",this.pdfSrc ) 
           })   
          }
  
         ngOnInit() {
  
         } 
   }
  </code></pre>
  
  <p><strong>Problem:1</strong></p>
  
  <p>Access to fetch at '<a href="http://localhost:8000/uploads/books/1548048467_sw.pdf" rel="nofollow noreferrer">http://localhost:8000/uploads/books/1548048467_sw.pdf</a>' from origin '<a href="http://localhost:4200" rel="nofollow noreferrer">http://localhost:4200</a>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.</p>
  
  <p><strong>Problem:2</strong></p>
  
  <p>core.js:15714 ERROR Error: Uncaught (in promise): DataCloneError: Failed to execute 'postMessage' on 'Worker': TypeError: Failed to fetch could not be cloned.
  Error: Failed to execute 'postMessage' on 'Worker': TypeError: Failed to fetch could not be cloned.</p>
  
  <p><strong>N.B.</strong> backend Laravel 5.7</p>
  
  <p>cors.php </p>
  
  <pre><code>header('Access-Control-Allow-Origin', 'http://localhost:4200')
              -&gt;header('Access-Control-Allow-Methods',' GET, POST, PATCH, PUT, DELETE, OPTIONS')
              -&gt;header('Access-Control-Allow-Headers','Origin, Content-Type, X-Auth-Token , Authorization');
  </code></pre>