-
Notifications
You must be signed in to change notification settings - Fork 80
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
Import of HttpClientModule within ngx-md clobbers existing interceptors #159
Comments
Why markdown library even needs HttpClientModule? |
@vajda <ngx-md [path]="'/path/to/code.cpp'"></ngx-md> @nuwang But I'm trying to understand the issue here. Could you create a https://stackblitz.com/ demo app? |
@dimpu Thanks for looking into this. The issue is that the HttpClientModule is only supposed to be imported once per application (as stated in the Angular docs). However, ngx-md imports the HttpClientModule internally, which has bizarre, unintended side-effects. The recommended solution to this issue is to simply not import the HttpClientModule within ngx-md. Instead, users of ngx-md should manually import HttpClientModule at the app level. For a more full discussion of this issue, see here: angular/angular#20575. In all these cases, the fix is for modules such as ngx-md to not import the HttpClientModule. |
@dimpu Is this issue being solved? I spent hours on trying to find where the problem was. It can break your whole app if you for example use interceptor to attach authorization headers to your http request. Correct way to create a library which needs HttpClientModule is to list it as peer dependency and left it on the user to provide in his module. I can offer PR if you want, thanks |
@mhamern |
Ngx-md imports the HttpClientModule internally. However, this will overwrite existing application interceptors, such as the XSRFInterceptor, which can cause module wide misbehaviour.
For a similar issue in another module, please see this issue:
MurhafSousli/ngx-sharebuttons#174
and the corresponding fix:
MurhafSousli/ngx-sharebuttons@a503936#diff-09baae46def54c6afaeed08d24cf8bc2
The text was updated successfully, but these errors were encountered: