I am trying to view pdf file using ngx-extended-pdf-viewer in angular with ASP.net Core as backend. This is my template:
<ngx-extended-pdf-viewer [src]="pdfsrc"
[height]="'95%'"
useBrowserLocale="true"
[textLayer]="true"
[showHandToolButton]="true"
>
</ngx-extended-pdf-viewer>
in my component.ts
pdfsrc: any;
this.pdfsrc = this.children.studyPath;
this.sanitizer.bypassSecurityTrustResourceUrl(this.pdfsrc)
CORS policy in ASP.Net Core
app.UseCors(policy => policy.AllowAnyHeader().AllowAnyMethod().WithOrigins("https://localhost:4200"));
I am getting this error Access to fetch at
'https://localhost:5001/ChildStudyReportFolder/7a6c78dd-aa3a-46db-bbea-37a456784d1a.pdf' from origin 'https://localhost:4200' 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.