Wrong response url with Angular and Net5.0

Stimulsoft Reports.WEB discussion
Post Reply
hassanbardan
Posts: 5
Joined: Wed Aug 17, 2022 2:16 pm

Wrong response url with Angular and Net5.0

Post by hassanbardan »

Our api send a http response instead of https.

Error:

Code: Select all

The page at 'https://insite-test.zeppelin-rental.de/sw/admin/reports' was loaded over HTTPS, but requested an insecure stylesheet 'http://insite-test.zeppelin-rental.de/v1/reports/8d672dae-b2ca-423b-9303-d3ccbd1df921/sti-designer/39304478-4c32-4326-a364-d283509be076?stiweb_component=Designer&stiweb_action=Resource&stiweb_cachemode=cache&stiweb_version=2022.3.4&stiweb_theme=Office2013WhiteCarmine'. This request has been blocked; the content must be served over HTTPS
Angular:

Code: Select all

<stimulsoft-designer-angular *ngIf="showDesign" (loaded)="designerLoaded()" [requestUrl]="designerUrl" [height]="innerHeight" [width]="innerWidth">Loading designer …</stimulsoft-designer-angular>

Code: Select all

public designerLoaded() {
      let viewerId = this.designer.designerEl.nativeElement.firstChild.jsObject.options.viewerId;
      window["js" + viewerId + "Parameters"].options.requestUrl = window['js' + viewerId + 'Parameters'].options.requestUrl.replace('http:', 'https:');
      window["js" + viewerId + "Parameters"].options.requestAbsoluteUrl = window['js' + viewerId + 'Parameters'].options.requestAbsoluteUrl.replace('http:', 'https:');
      window["js" + viewerId + "Parameters"].options.requestResourcesUrl = window['js' + viewerId + 'Parameters'].options.requestResourcesUrl.replace('http:', 'https:');
      window["js" + viewerId + "Parameters"].options.requestStylesUrl = window['js' + viewerId + 'Parameters'].options.requestStylesUrl.replace('http:', 'https:');
   }
API:

Code: Select all

[HttpGet]
		public IActionResult Get() {
			this.logger.LogTrace($"{nameof(DesignerController)}.{nameof(Get)}()");

			try {
				var requestParams = StiAngularDesigner.GetRequestParams(this);
				requestParams.HttpContext.Request.CoreRequest.Path = HttpContext.Request.PathBase + HttpContext.Request.Path;
				requestParams.HttpContext.Request.CoreRequest.IsHttps = true;
				if (requestParams.Action == StiAction.Undefined) {
					var options = new StiAngularDesignerOptions {
						Actions = new Stimulsoft.Report.Mvc.StiNetCoreDesignerOptions.ActionOptions {
						},
						Server = new Stimulsoft.Report.Mvc.StiNetCoreDesignerOptions.ServerOptions { UseRelativeUrls = true
						},
						//Appearance = new Stimulsoft.Report.Mvc.StiNetCoreDesignerOptions.AppearanceOptions {
						//},
						FileMenu = new Stimulsoft.Report.Mvc.StiNetCoreDesignerOptions.FileMenuOptions {
							ShowClose = false,
							ShowExit = false,
							ShowNew = false,
							ShowOpen = true,
							ShowSave = true,
							ShowSaveAs = false,
							Visible = true,
						},
						Theme = StiDesignerTheme.Office2013WhiteCarmine,
						//Toolbar = new Stimulsoft.Report.Mvc.StiNetCoreDesignerOptions.ToolbarOptions {
						//}
						Behavior = new Stimulsoft.Report.Mvc.StiNetCoreDesignerOptions.BehaviorOptions {
							SaveReportAsMode = StiSaveMode.Hidden,
							SaveReportMode = StiSaveMode.Visible,
							ShowSaveDialog = false,
						}
					};
					//options.Server.UseRelativeUrls = true;

					var dataResult = StiAngularDesigner.DesignerDataResult(requestParams, options);
					return dataResult;
				}

				return StiAngularDesigner.ProcessRequestResult(this);
			}
			catch (Exception ex) {
				return this.CreateErrorResponse(ex);
			}
		}

Code: Select all

[HttpPost]
		public async Task<IActionResult> Post(Guid reportUid, Guid userUid/*, Uri backUri*/) {
			//this.logger.LogDebug($"{nameof(DesignerController)}.{nameof(Post)}({nameof(reportUid)}={reportUid:B}, {nameof(userUid)}={userUid:B}, {nameof(backUri)}={backUri:B})");
			this.logger.LogDebug($"{nameof(DesignerController)}.{nameof(Post)}({nameof(reportUid)}={reportUid:B}, {nameof(userUid)}={userUid:B})");

			try {
				if (this.User == null) { throw new ArgumentNullException(nameof(ClaimsPrincipal)); }

				var requestParams = StiAngularDesigner.GetRequestParams(this);

				if (requestParams.ComponentType == StiComponentType.Designer) {
					switch (requestParams.Action) {
						case StiAction.GetReport:
							return await this.GetReport(reportUid, userUid);

						case StiAction.SaveReport:
							await this.SaveReport(reportUid, userUid);
							//return this.Redirect(HttpUtility.UrlDecode(backUri.ToString()));
							return this.NoContent();

						case StiAction.Exit:
							//return this.Redirect(HttpUtility.UrlDecode(backUri.ToString()));
							return this.NoContent();
					}
				}

				return await StiAngularDesigner.ProcessRequestResultAsync(this);
			}

Code: Select all

public async Task<IActionResult> GetReport(Guid reportUid, Guid userUid) {
			this.logger.LogDebug($"{nameof(DesignerController)}.{nameof(GetReport)}({nameof(reportUid)}={reportUid:B}, {nameof(userUid)}={userUid:B})");

			try {
				var reportResponse = await this.reportQueryService.GetReport(reportUid, userUid);
				var report = StiReport.CreateNewReport();

				if (reportResponse.Layout == string.Empty) {
					report.Load(StiAngularHelper.MapPath(this, "Reports/ReportTemplate.mrt"));
				}
				else {
					report.LoadPackedReportFromString(reportResponse.Layout);
				}
				var requestParams = StiAngularDesigner.GetRequestParams(this);
				requestParams.HttpContext.Request.CoreRequest.IsHttps = true;
				return await StiAngularDesigner.GetReportResultAsync(requestParams, report);
			}
			catch (Exception ex) {
				return this.CreateErrorResponse(ex);
			}
		}

I tried everything but everytime same problem.
Attachments
anydesk00016.png
anydesk00016.png (232.55 KiB) Viewed 3591 times
anydesk00015.png
anydesk00015.png (368.35 KiB) Viewed 3591 times
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Wrong response url with Angular and Net5.0

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
#7820
hassanbardan
Posts: 5
Joined: Wed Aug 17, 2022 2:16 pm

Re: Wrong response url with Angular and Net5.0

Post by hassanbardan »

Is there a way to force https?
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: Wrong response url with Angular and Net5.0

Post by Vadim »

Hello.

Please in StiAngularDesignerOptions setup path to css into options.Appearance.CustomCss
hassanbardan
Posts: 5
Joined: Wed Aug 17, 2022 2:16 pm

Re: Wrong response url with Angular and Net5.0

Post by hassanbardan »

I got it. Next problem is he xhr request in the next request. Can I set a path for the xhr request?
Max Shamanov
Posts: 786
Joined: Tue Sep 07, 2021 10:11 am

Re: Wrong response url with Angular and Net5.0

Post by Max Shamanov »

Hello,

We need time to prepare an answer for you.

Thank you
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: Wrong response url with Angular and Net5.0

Post by Vadim »

Hello.

From next version 2022.4.1 you can use options.Server.RouteTemplate = "https://mysite.com/api/designer";
hassanbardan
Posts: 5
Joined: Wed Aug 17, 2022 2:16 pm

Re: Wrong response url with Angular and Net5.0

Post by hassanbardan »

Code: Select all

this.HttpContext.Request.Scheme = "https";
was the solution
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Wrong response url with Angular and Net5.0

Post by HighAley »

Hello,

We were glad to help you.
Let us know if you need any additional help.

Thank you.
Post Reply