892 questions
2
votes
1
answer
137
views
Does the httpResource have an HttpContext?
httpResource got released as an experimental feature in Angular 19.2. The httpResource uses the HttpClient under the hood. So I was hoping, I would be able to pass all the options I could pass to the ...
1
vote
0
answers
144
views
Angular HttpClient interceptor: Error 429 returns status 0 instead of 429
I am working with an Angular HTTP interceptor and handling various error status codes. However, I have an issue with handling the 429 (Too Many Requests) error code. While the backend correctly ...
1
vote
1
answer
53
views
Functional style interceptors - How to provide them with dependencies
Imagine the situation where you provide any lib to client. Simple scenario, spinner interceptor which needs spinner service.
In old way it was possible to:
providers: [
{
provide: ...
2
votes
1
answer
122
views
Angular | Why catchError does't catch 401 error?
Listen, I'll explain how it all happens.
I'm making a refresh system for a jwt token. It's a standard thing. I configured exactly two systems: guards and interceptors. That's why I'm sure people will ...
1
vote
1
answer
79
views
Angular request duplicate if error is throw
I have a weird behavior with my requests. If the request throw an error, I automatically get a second one launched
Here is an example of my request :
this.http.post(environment['url'] + '/ws/verifier/...
0
votes
2
answers
103
views
"expression has changed after it was checked" error despite having the right setup
I'm facing the error expression has changed after it was checked. I know, that this check runs only in dev mode (runs twice) and that I won't have the error message in prod. But I want to know why I ...
0
votes
0
answers
73
views
Angular Interceptor repeating every request 3 times
I have an interceptor for refreshing an access token, when it doesn't refresh, everything's all good, but when it does, the unfortunate request that happened to pass through it when it decided to ...
0
votes
1
answer
41
views
Angular interceptor stopping all http requests
I have an interceptor that is supposed to refresh an access token if it's expired and continue the request with the new token, but its just looping a lot (not infinitely, something is stopping it ...
1
vote
1
answer
52
views
Angular 17: What use to to fetch data at the app start moment?
there is an issue.
I have Angular 17 app.
There is a need to get a user data by http request as to keep it in localStorage and use everywhere.
The request should be send once only and as earlier as ...
0
votes
0
answers
62
views
switchMap is not executing its code in Http Interceptor
I am facing an issue with the switchMap in interceptor.
But in angular service it works fine. unable to find the reason why switchMap is not executing its code.
Need help please.
getAccessToken
...
0
votes
1
answer
108
views
Calling api request inside an interceptor for jwt refresh token going to an infinite loop
I am trying to implement the the refresh jwt token mechanism in an interceptor.
I am following the accepted answer way in this post
Angular - Waiting for refresh token function to finish before ...
5
votes
1
answer
419
views
How to use provideHttpClient with route-specific interceptors in Angular?
I'm trying to set up provideHttpClient in Angular v19 to use route-specific interceptors, but I'm encountering an issue where no requests are intercepted.
My Setup:
I have a default ApplicationConfig ...
1
vote
1
answer
234
views
How to test an Angular interceptor with a retry strategy?
This is a simplified version of my Angular 18 error interceptor. It will retry requests that produced an error to make sure it was not a fluke (please don't ask!). This works, however I am running ...
1
vote
1
answer
51
views
Angular Interceptor - re-execute the same HTTP Interceptor after a catch
I'm looking for a solution to re-execute the same HTTP query after a catch is completed.
For instance, as per below, I would like to re-execute the same call as the catch hanlded properly the re-...
0
votes
1
answer
42
views
Angular Interceptor - retrieve Graphql query or mutation name
Good morning everyone,
I would need your help to retrieve the query or mutation name within the interceptor which is working fine.
import { HttpContextToken, HttpInterceptorFn } from '@angular/common/...
2
votes
1
answer
111
views
HttpContextToken always false while using HttpInterceptorFn
I am implementing a loading spinner that runs for all my http requests via an HttpInterceptorFn using this blog post as a guide: https://blog.angular-university.io/angular-loading-indicator/
loading....
2
votes
1
answer
94
views
Angular auth bug guard and interceptor
I want to do token-based authorization with angular, but I have a bug like this
I can protect pages with auth guard if the token has not exploded, but I cannot use the interceptor because auth guard ...
1
vote
2
answers
74
views
Using fresh cookies from catch Error in HttpIntercopterFn
I have created an interceptor to ensure that every request sends HttpOnly JWT/refresh tokens. I am attempting to refresh my short-lived JWT by catching a 401 error and asking the server for a refresh. ...
0
votes
3
answers
308
views
Angular effect() does not redirect to the home page after logout and re-login
I'm using ngrx signal store, and I have a login method that updates my state with isAuthenticated: true and token: token. It also stores the token in localStorage. I have a withComputed((store) => (...
1
vote
0
answers
200
views
Angular 17 Interceptor Not Adding Bearer Token on Initial Login Request
I'm working on an Angular 17 application where I'm trying to add an Authorization Bearer token to the request headers upon login. However, I'm facing an issue where the HttpInterceptor retrieves null ...
0
votes
1
answer
240
views
Restrict cookies in the request header for the APIs
I am developing an application with the following stack
Frontend - Angular
Backend - JAVA Springboot
Both the applications are hosted on the same domain.
When I am logging into my application, the ...
1
vote
1
answer
159
views
Angular 18.0.5 not seeing the interceptor and not working
I believe with standalone component and HttpInterceptor has a bug!
export const appConfig: ApplicationConfig = {
providers: [
// provideHttpClient(withInterceptorsFromDi()),
// { provide: ...
2
votes
1
answer
3k
views
Angular 18: set InjectionToken after APP_INITIALIZER provider
In angular 18, I need to set API URL after the app initialisation(because for obvious reason, fetching of URL from a json file). However it is not setting. In fact InjectionToken has set before ...
0
votes
2
answers
65
views
Angular login and http-interceptor - runtime problem
I use this function to login:
login() {
this.authService.login(this.ngForm.value).subscribe({
next: (response) => {
const loginData = response;
this.user = loginData.user;
this....
1
vote
1
answer
497
views
Optimizing Angular HTTP Interceptor for Refresh Token
I'm working on an Angular application with an HTTP interceptor for handling authentication tokens. I'm facing a couple of challenges and need guidance on best practices.
The interceptor currently ...
1
vote
5
answers
7k
views
HttpInterceptors and Dependency Injection Angular 18
I'm setting up a JWT interceptor in Angular 18.. I had this set up in Angular 8, although that was a completely different setup using a class which inherits HttpInterceptor. here I am using function ...
2
votes
2
answers
2k
views
Angular 18.0.5 not seeing the interceptor
Angular is not aknowledging the interceptor.
So basically I executed
ng generate interceptor JwtInterceptor
and setup set it up to add the token to the header :
import { HttpErrorResponse, ...
1
vote
2
answers
1k
views
How use async function in angular 17 function based Http Interceptor
I have an interceptor that adds the access token to every request. The only problem is, the only way I can get this access token is by using a function that returns a Promise:
async getToken(): ...
0
votes
2
answers
52
views
Angular 15, .pipe .subscription response modifications
let data = { ticketId: id };
this.apiService
.call("tickets", "/detail", "GET", true, data, null)
.pipe(first())
.subscribe(
(data) => {
data = this....
2
votes
1
answer
647
views
Type 'unknown' is not assignable to type 'HttpEvent<any>' - Trying to create HTTP interceptor in Angular app
I have been trying to create a loading spinner in my Angular application.
I found an interesting tutorial here.
It was all going pretty well, until the final step, when I need to actually create the ...
2
votes
1
answer
1k
views
How to Implement a Loading Spinner for HTTP Calls in Angular 17?
I am working on an Angular 17 project and need to implement a loading spinner that displays during HTTP calls. I want the spinner to show when a request or several is made and hide once the response ...
0
votes
1
answer
403
views
How to use the NGRX selectors inside an interceptor without deprecated commands
In my app I created by using Angular 17 I have a very simple interceptor:
import { HttpInterceptorFn } from '@angular/common/http';
import { HttpBodyModel } from "../models/http-body.model";
...
1
vote
1
answer
106
views
Angular interceptor error handling put & delete method problem
I show an alert based on the http response returned in Angular. My code works in Get and post methods, but not in put and delete methods.I'm stuck here and would be very happy if someone could help me....
1
vote
1
answer
926
views
Implementation of interceptors in angular 17
how do I inject an interceptor to an application generated as a modular app in angular 17? I mean the one generated with the --standalone argument?
I tried injecting it as [provideHttpClient(...
0
votes
1
answer
628
views
Angular 17 - HttpInterceptorFn - Queue http requests while renew token service is not finished
In an Angular 17 project, with HttpInterceptorFn, I meet a concern when renewing an authentication token. Indeed, when two requests arrive while the two have an expired token, two renewal requests are ...
1
vote
1
answer
173
views
Why does this interceptor only trigger on the Sent-Event, but not the actual response?
I'm receiving some multipart/mixed content from a server that contains some JSON as well as bytes and need to parse it into an object in Angular.
This is how I send out my request:
public sendRequest(...
1
vote
0
answers
190
views
Concurrency problems when using refresh token interceptor and NgRx pattern in Angular
I am using Angular 17 with the NgRx pattern. I'm trying to implement an interceptor to append the correct headers to requests made to the backend.
In particular, the logic to follow, according to the ...
0
votes
1
answer
158
views
ngx-translate not working with interceptor in Ionic Capacitor app
I'm facing an issue with ngx-translate while integrating it with an interceptor in my Ionic Capacitor application. When attempting to access the translate service within the interceptor, I facing the ...
1
vote
1
answer
2k
views
Retry original request with HttpInterceptorFn in Angular 17 (Functional Http Interceptor)
I'm having trouble when my interceptor is intercepting a request based on a JWT expiration. I'm able to perform the refresh of the token, but the original request is never retried again.
I have the ...
0
votes
1
answer
856
views
Angular error interceptor - Multiple 401 responses
I'm currently working on implementing a refresh token mechanism in my Angular frontend. When my backend returns a 401 error, my error interceptor handles it. However, I'm facing an issue: when my ...
16
votes
3
answers
12k
views
How to inject a dependency in HttpInterceptorFn in angular 17?
Here is my interceptor using the new way of intercept of angular, using a function instead of a class
export const errorInterceptor: HttpInterceptorFn = (req, next) => {
console.log('Intercepted')...
3
votes
2
answers
5k
views
How to use functional interceptor for refreshing token in Angular 17
I was using the following class-based interceptor to refresh user token:
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
constructor(private inject: Injector) {}
...
2
votes
1
answer
522
views
enabling CSRF via Angular HttpClientModule, error: TS2552: Cannot find name HttpXsrfInterceptor
Question comming from a front-end beginner. I would like to add csrf tokens to some of the requests in a frontend app. The application is using Angular in version 12.2.17. I follow instructions from ...
0
votes
0
answers
42
views
Interceptor event always throws error after login to application
Interceptor event always throws error and error block geting exicuting.
We are upgrading our existing angular10 application to Angular 15. After upgradation we are facing issue whicle login to ...
0
votes
1
answer
656
views
How to do a service call in interceptor & execute the next steps only once that is completed- async call to a service in Angular Interceptor
I am trying to do a service call in the interceptor with below code piece-enter image description here
However i am getting below error after running it-enter image description here
SO when i put a ....
1
vote
2
answers
1k
views
Angular Http Interceptor - Modifying headers causes CORS
I have defined an http interceptor. Inside the interceptor I have the following code:
let newReq = req.clone({
withCredentials: true,
responseType: 'json'
});
Now I need to modify all requests ...
0
votes
0
answers
121
views
angular interceptor trying to make a interceptor which queue the request of max request 10
# import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
# import { Injectable } from '@angular/core';
# import { Observable, interval } from 'rxjs';
# import { ...
0
votes
0
answers
126
views
Why do I need a subscribe in my interceptor function?
All of the examples that I'm following (https://github.com/bartosz-io/jwt-auth-angular), do not have a subscribe in the code, but it is the only way I can get my interceptor function to work. Notice ...
1
vote
1
answer
539
views
Reauthenticating Firebase User Token with Angular and HTTP Interceptor
I am running into a strange issue when using error catching within my Angular HTTP Interceptor code.
It seems that code in my chain of ".then()" statements is triggering out of order somehow....
2
votes
1
answer
642
views
Angular: How to queue HTTP requests when encountering a 401 error?
I have an Angular application that uses JWT tokens for authentication. When an HTTP request returns a 401 error (unauthorized), I need to refresh the token and retry the request.
My previous Question ...