jsreport / jsreport-dotnet

jsreport .NET sdk home repository
https://jsreport.net
MIT License
63 stars 10 forks source link

Getting unauthorized access for JS Report .Net Core issue in remote server hosted with IIS #37

Closed sureshpoudel closed 2 years ago

sureshpoudel commented 5 years ago

I am working in .net core 2.1 have jsreport.aspnetcore(2.0.1) have jsreport.Binary(2.5.0) have jsreport.Local(2.1.0) I am using chromePdf recipe I do not have issue working in debug mode in VS 2017 and running in localhost using IIS. But when I deploy same published code in the remote machine and try to access it show up without any formatting. below is the log

+0 Starting rendering request 1 (user: null) +0 Rendering anonymous template { recipe: chrome-pdf, engine: none } +0 Data item not defined for this template. +0 Resources not defined for this template. +16 Base url injected: http://test.test.com(renamed actual url) +16 Rendering engine none +47 Compiled template not found in the cache, compiling +47 Executing recipe chrome-pdf +5125 Converting with chrome HeadlessChrome/76.0.3803.0 using dedicated-process strategy +7687 Failed to load resource: the server responded with a status of 401 (Unauthorized) +7687 Failed to load resource: the server responded with a status of 401 (Unauthorized) +7687 Failed to load resource: the server responded with a status of 401 (Unauthorized) +7687 Failed to load resource: the server responded with a status of 401 (Unauthorized) +7780 Failed to load resource: the server responded with a status of 401 (Unauthorized) +7780 Failed to load resource: the server responded with a status of 401 (Unauthorized) +7791 Failed to load resource: the server responded with a status of 401 (Unauthorized) +7791 Failed to load resource: the server responded with a status of 401 (Unauthorized) +7855 Running chrome with params {"margin":{},"printBackground":true} +8198 Skipping storing report. +8198 Rendering request 1 finished in 8198 ms

pofider commented 5 years ago

It is trying to load your css from your http server but these resources are behind your authorization.

Base url injected: http://test.test.com(renamed actual url)

We inject to the html base tag which causes that your relative resource urls like '/css/mystyles' are resolved as 'https://yourapp.com/css/mystyles'. It seems you have them behind authentication.

You need to make them public or read their content and embed it inline to the html.

sureshpoudel commented 5 years ago

Thank you, It worked for inline styling.
As you know for .net core apps css is always inside wwwroot folder. Do you have any plan to make this path setting configurable or default it to wwwroot\css for .net core applications? Something inside configure.... services.AddJsReport(new LocalReporting() .Configure(cfg => cfg.AllowedLocalFilesAccess().BaseUrlAsWorkingDirectory()) .UseBinary(JsReportBinary.GetBinary()) .AsUtility() .Create());

tietoTomas commented 3 years ago

I have the same problem but cannot solve it with inline. Is there any way to configure the path?

pofider commented 2 years ago

A lot has changed in the jsreport v3 sdk, please test it there and come back if you have still troubles.