Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable overriding HttpErrorHandlerInterceptor #19541

Open
timdk opened this issue Nov 13, 2024 · 0 comments
Open

Enable overriding HttpErrorHandlerInterceptor #19541

timdk opened this issue Nov 13, 2024 · 0 comments

Comments

@timdk
Copy link

timdk commented Nov 13, 2024

Is your feature request related to a problem? Please describe.

Related to new feature Server-Side Rendering Error Handling

We can add additional interceptors but can't replace or extend the OOTB implementation.

I think that overriding it is supposed to be possible due to the following statement in the documentation

The composable storefront HttpErrorHandlerInterceptor treats all outbound HTTP as a reason to make SSR fail.

However, if this assumption is not true for your application, you can customize it by over-providing the composable storefront HttpErrorHandlerInterceptor.

Describe the solution you'd like

The service is provided with useClass and it doesn't have the providedIn: 'root' annotation.

@Injectable()
export class HttpErrorHandlerInterceptor implements HttpInterceptor {
// HttpErrorHandlerModule
{
  provide: HTTP_INTERCEPTORS,
  useClass: HttpErrorHandlerInterceptor,
  multi: true,
},

I would like to replace it like so:

{
  provide: HttpErrorHandlerInterceptor,
  useClass: CustomHttpErrorHandlerInterceptor,
},

The WithCredentialsInterceptor is provided in root and injected using useExisting.

@Injectable({ providedIn: 'root' })
export class WithCredentialsInterceptor implements HttpInterceptor {
// BaseOccModule
{
  provide: HTTP_INTERCEPTORS,
  useExisting: WithCredentialsInterceptor,
  multi: true,
},

The following override works

{
  provide: WithCredentialsInterceptor,
  useClass: CustomWithCredentialsInterceptor,
},

Describe alternatives you've considered

Adding additional interceptors works for now, but multiple errors are logged. E.g. from my SSR logs:

{
  message: 'ProductNotFoundOutboundHttpError: Product Not Found\n' + ...
},
{
  message: 'OutboundHttpError: Outbound HTTP Error\n' + ...
},
{
  message: 'Error: Failed to set cms page index\n' + ...
}

The OutboundHttpError is coming from the base HttpErrorHandlerInterceptor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant