Attività di "rmosley@yprime.com"

I've written a custom error handler that uses the Content Projection Service to display an error message to the user, using the AppendComponentToBody projection strategy. However I would like these error messages to behave much like the 404, page not found error. In that they remove the theme, and is the only component displayed.

How can I go about doing this?

import { ContentProjectionService, PROJECTION_STRATEGY } from '@abp/ng.core';
import { HttpErrorResponse } from '@angular/common/http';
import { ErrorHandler, Injectable, Injector } from '@angular/core';
import { ErrorHandlingComponent } from './error-handling.component';

@Injectable()
export class RouteErrorHandler implements ErrorHandler {

    constructor(
        private readonly injector: Injector
    ) { }

    handleError(error: Error): void {
        if (error instanceof HttpErrorResponse) 
            return;       

        const contentProjection = this.injector.get(ContentProjectionService);

        var errorMessage: any;
        errorMessage = error.message;
        if (errorMessage && (typeof errorMessage === 'string' || errorMessage instanceof String)) {
            errorMessage = errorMessage.replace(/<[^>]*>/g, '');
        }

        contentProjection.projectContent(PROJECTION_STRATEGY.AppendComponentToBody(ErrorHandlingComponent, { code: 403, error: errorMessage }));
        return;
    }
}

Current Result:

Desired Result

This worked perfectly! Thanks!

I've recently updated our angular app to use Auth0 for authentication and authorization, almost everything is working so far. The issue I'm having is when signed into a non-host tenant a '_tenant' header gets automatically added to all API requests.

When the '_tenant' header is included to Auth0's ./well-known/openid-configuration endpoint the error response is 'Request header field __tenant is not allowed by Access-Control-Allow-Headers in preflight response This is only occurring when signed into a tenant, the host tenant does not include this header and does not receive this error response.

Is there a way to exclude the '_tenant' header to this, and other Auth0 endpoint?

Full error message: Access to XMLHttpRequest at 'https://{removed}/.well-known/openid-configuration' from origin 'https://localhost:4200' has been blocked by CORS policy: Request header field __tenant is not allowed by Access-Control-Allow-Headers in preflight response.

  • ABP Framework version: v6.0.1
  • UI type: Angular
  • DB provider: EF Core MSSQL
  • Tiered (MVC) or Identity Server Separated (Angular): Angular
1 - 3 di 3
Made with ❤️ on ABP v8.2.0-preview Updated on marzo 25, 2024, 15:11