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

Fileupload breaks http requests interceptor cycle when imported in a standalone context #15360

Closed
pplaissy opened this issue Apr 25, 2024 · 1 comment · Fixed by #15361
Closed
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@pplaissy
Copy link
Contributor

Describe the bug

Hi!

Say we have a standalone app

// an app config file which register a http interceptor
export const appConfig: ApplicationConfig = {
  providers: [
    provideHttpClient(withInterceptors([
      apiRequestsInterceptor
    ])), 
    provideAuth(authConfig)
  ]
};

// the http interceptor
export const apiRequestsInterceptor: HttpInterceptorFn = (req: HttpRequest<unknown>, next: HttpHandlerFn) => {
  console.log("intercepted");
  // here the access token is added to headers
};

// and finally a component
@Component({
  selector: 'test',
  standalone: true,
  imports: [],
  templateUrl: './test.component.html'
})
export class TestComponent {
}

Everything works fine until I import the Fileupload component.
From this import, the interceptor is ignored.

import { FileUploadModule } from 'primeng/fileupload';
@Component({
  selector: 'test',
  standalone: true,
  imports: [FileUploadModule],
  templateUrl: './test.component.html'
})
export class TestComponent {
}

It's because Fileupload imports itself HttpClientModule which is incompatible in standalone context.

I'm going to make a pull request to suggest the fix.

Environment

angular 17 standalone app

Reproducer

https://stackblitz.com/edit/github-7yclho?file=src%2Fapp%2Fapp.component.html

Angular version

17.3.5

PrimeNG version

17.14

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

0

Browser(s)

No response

Steps to reproduce the behavior

  1. Open the console to see if the request was intercepted.
  2. click on the 'end api call' button
  3. nothing to see in the console -> the requests are not intercepted
  4. remove the FileUpload import in the app.component.ts file
  5. click on the 'end api call' button
  6. the console log display 'intercepted' on each click

Expected behavior

No response

@pplaissy pplaissy added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 25, 2024
@cetincakiroglu cetincakiroglu added this to the 17.15.0 milestone Apr 26, 2024
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 26, 2024
@cetincakiroglu
Copy link
Contributor

Fixed in #15360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants