64 questions
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
257
views
Auth Interceptor is not firing [duplicate]
I have an Angular v19 project.
I have the following AuthInterceptor
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
private isRefreshing = false;
constructor(private ...
1
vote
2
answers
179
views
HTTP GET throws TypeError: Cannot read properties of undefined (reading 'length')
I want to use a simple method to check for internet connectivity. We have a file hosted on a server and I simply want to check that we can see it.
The file contains:
{
"status": "...
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....
1
vote
1
answer
707
views
Interceptor doesn't activate and set the header in Angular 18
My interceptor doesn't work in Angular version 18. The backend says it can't add the header to the request:
Pre-authenticated entry point called. Rejecting access
2024-09-29T12:39:52.861+02:00 DEBUG ...
1
vote
2
answers
523
views
401 Unauthorized Error during token refresh API call
I can't solve the implementation of refresh tokens, my backend is OK at PostMan works OK, with a curl command it's OK too, I send the header with a refresh token and the backend responses with an ...
1
vote
1
answer
67
views
Replay a failed request with new token
I am trying to replay a failed request once a token has been refreshed. Following this as a guide.
My http interceptor:
isRefreshingToken: boolean = false
tokenSubject: Subject<void> = new ...
1
vote
1
answer
370
views
Angular 17 SSR, Interceptor
Developing Angular 17 SSR applications, JWT Authentication
I developed login component, and trying to get the user info from JWT.
But, I'm not able to work with Interceptor & localStorage
...
0
votes
1
answer
81
views
New Interceptors from Angular 17, local use of a BehaviorSubject does not work
In the new definition of interceptors in Angular 17, the local use of a BehaviorSubject does not work.
I have an interceptor that seeks to fulfill the use case of the refreshToken by seeking to ...
1
vote
0
answers
389
views
Angular 18: Interceptor Not Working After Upgrade from Angular 16
I am currently using Angular 18 for my application and my application is modular-based. Previously, my application was developed using Angular 16, but I have recently upgraded it to Angular 18. ...
1
vote
1
answer
111
views
How to check if an interceptor is provided in withInterceptors fucntion
In my library, There is an interceptor that the user must provide in order for the component to work.
I want to throw an exception if the user forgets to provide the interceptor, maybe from a ...
0
votes
1
answer
200
views
provide http interceptor via a provider function
In my library, I export a http interceptor.
Currently to activate the interceptor, the user must use the following code:
import { provideNgProgressHttp, progressInterceptor } from 'ngx-progressbar/...
2
votes
3
answers
2k
views
Recently started a new concept called Interceptor in Angular 17, but I got the error while practice
I tried to implement the interceptor concept in my angular demo project but I'm getting error on httpInterceptor line 7 i.e
`export const httpInterceptor: HttpInterceptorFn = (req, next) => {`
I'm ...
2
votes
2
answers
5k
views
HTTP Interceptor is not working in Angular 17 project
My AuthInterceptor.intercept method is not getting called. Putting all necessary codes below. My code flow: FormSubmit() method from login.component calls the generateToken() method from login.service(...
3
votes
2
answers
263
views
Call common api before intercept fires
My interceptor code:
import { Injectable } from '@angular/core';
import {
HttpInterceptor,
HttpRequest,
HttpHandler,
HttpEvent,
HttpErrorResponse,
...
-1
votes
1
answer
128
views
HttpInterceptor with member-variables
I made an interceptor-service for adding a auth-header to every HTTP-request.
Service
@Injectable ()
export class HttpInterceptorService implements HttpInterceptor
{
token : string = undefined;
...
2
votes
1
answer
70
views
After refreshing the token, the existing request to the original API replace with the /refersh-token API so I need to double check on button for data
When the token gets expired next: HttpHandler handle the request that comes from the server when it go inside the refershToken Subscribe method it goes to the header that I defined above the next....
19
votes
7
answers
33k
views
Interceptor not intercepting in Angular 17
I'm learning angular through course and currently I'm learning about Interceptors. The angular version in the course isn't 17 but the one which I'm using in my local is. So, after 1st trying to ...
0
votes
2
answers
960
views
Using angular snack bar to handle errors, but I already handeled errors in its interceptor
I wanna use snack bar to show users the error, I want to know if I have to use error in my subscription method to use snack bar? is there any way to not use error in subscribe method and show error ...
2
votes
2
answers
2k
views
Angular v16 Standalone component not working with Interceptor?
Angular version 16, MoneyComponent is a standalone component.
Application structure is
src\app\pages\money. Only one page moneyForms needs interceptor to send in additional info to API HttpPost, so ...
0
votes
1
answer
2k
views
How to intercept Websockets, Server Sent Events (SSE) and ReadableStream Request and Response in Angular?
I want stream real time data from server to client. We are using Angular 16. I want to intercept the Request and Response of WebSockets, Server Sent Events (SSE) and ReadableStream using Angular ...
0
votes
1
answer
679
views
How to inject application configuration and add HTTP interceptor to standalone component
I am doing it as follows but this is not possible as boostrapapplication expects 1 or 2 arguments.
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/...
0
votes
0
answers
141
views
Angular interceptor for switching requests
I want to create an interceptor (or any other solution that will affect all the services), that will hold the POST requests for ~300ms and in case there are new POST requests in that time gap, will ...
0
votes
1
answer
473
views
Providing functional interceptors without providing HttpClient
There is now new method of providing HttpClient as provideHttpClient function. This also can take withInterceptors() function to define interceptors.
I have shared module as a separate dependency that ...
0
votes
1
answer
125
views
Angular interceptor should use token and later refreshed token
I have an Angular project where I want to use a token. After about 1/2 hour, the interceptor should call a refresh endpoint and get a new token. But I am having trouple getting it to work.
import { ...
0
votes
0
answers
362
views
angular interceptor doesnt work for <img [src]="url" *ngIf="!isimageloading">
<img [src]="url" *ngIf="!isimageloading">
in a form with submit in html
in component
fetchImage(form:NgForm)
{
this.url="http://localhost:3000/getimage/"+...
1
vote
1
answer
548
views
HTTP Interceptor not working with service call
I have created an interceptor to add header, so that I don't have to manually add header to each http request. But the moment I add service call inside my interceptor it wouldn't trigger, I am not ...
0
votes
1
answer
160
views
How to apply interceptor in Angular only to POST requests? [closed]
Is it possible to apply interceptors in Angular only to POST requests?
2
votes
1
answer
1k
views
Router.navigate() not working inside functional interceptor
This is an Angular functional interceptor created to manage possible session timeouts during application usage.
export const sessionExpiredInterceptor: HttpInterceptorFn = (req, next) => {
...
0
votes
0
answers
74
views
Angular catchError in intercepter dialog not working
I am trying to show Unauthenticated dialog and let user to click on the return to logging page when there is 403 error. Below code works fine but dialog is getting disappear immediately before user ...
0
votes
1
answer
389
views
How to access cookies in angular UI set by backend running on different port
Please find my below use case:
There is a backend web service developed in Java running at http://localhost:8080 and an angular UI application running at http://localhost:4200. Now my requirement is ...
9
votes
2
answers
5k
views
How do I make the Prime MessageService work in the Interceptor of an Angular application that only uses Standalone Components?
I'm trying to implement a global error notification but I'm not managing to inject anything into the Interceptor and the worst thing is that it doesn't give an error, it just doesn't work, if anyone ...
0
votes
1
answer
427
views
Unit Testing Angular HttpInterceptor: toHaveBeenCalledWith apears never called
I am unit testing a little error-handling interceptor and I want to test that a certain function has been called with arguments. The toHaveBeenCalledWith function gives a "but it was never called&...
0
votes
0
answers
567
views
Unable to log in to a spring boot OAuth2 Resource Server application from an angular application
I built a small spring boot application using spring-boot-starter-oauth2-resource-server. The tests work well on Postman but not on Angular. The test was working on Angular when I used spring-boot-...
0
votes
1
answer
90
views
Angular14 Service CORS and Authentication Header
I have an Angular 14 app that I'm just starting out with that will be using Authorization headers to call a webapi (c#) in a different domain, so CORS is hitting me. What I can't figure out is how to ...
0
votes
1
answer
651
views
How to delete muliple httpparams in angular
I'm adding custom params for API's for some use case which is not require to send it BE and I want to delete them before sending to BE.
Url: https://www.dummy.com?reload=true
params: req.params.delete(...
1
vote
1
answer
475
views
LoaderService issue using MSAL Service for login in Angular
I'm developing an Angular app that requires MS credentials for get logged in. Furthermore I'm using an Http Interceptor for showing up a loader component when any HttpClient's call is in use.
My ...
0
votes
0
answers
1k
views
How to call API service inside Interceptors Angular
I am trying to call API service inside the interceptor.
My API service code:
showAcknowledgement() {
this.noticeService.getNotice(ConstUrls.NoticeManagement.GetUserNotice).subscribe((data: any) =&...
0
votes
0
answers
741
views
Angular 11 - subscribe does not return correct data for response type text
I have a weird problem. I hope I would be able to explain.
I am encrypting something in the backend and API response returns a plain string in encrypted format something like this:
jZAYo65r+...
-1
votes
1
answer
982
views
How to create user interface for rest api using spring boot [closed]
I have created a Rest API using springBoot and using Postman for creating GET, POST, PUT ,Delete Requests.
To display data to enduser i am using Angular .
My Application is Read only for enduser , and ...
5
votes
0
answers
500
views
Error when testing HttpInterceptor Angular 10
I'm working on an Angular 10 application that uses an HttpInterceptor for adding a specific header to all responses. Unfortunately, when trying to test this interceptor, I keep getting the following ...
2
votes
1
answer
852
views
Read the response header when the status is 302 in Angular
How can I read the response header of XHR call by $http in Angular (v8+) as its status is 302 and it is redirected by browser?
In my case as the redirect url has a different origin, I only get an ...
0
votes
1
answer
1k
views
Unit testing the intercept function in an Angular HTTP interceptor
I've written an Angular 9 HTTP Interceptor, and I would like to unit test the intercept function in relative isolation. From what I've seen on StackOverflow already, people are suggesting to make fake ...
4
votes
2
answers
3k
views
Interceptor not intercepting, despite only one HttpClientModule
I have application in Angular and I have only one HttpClientModule, but when I provide HttpClient in constructor like this:
export class UserService {
constructor(private http: HttpClient /** <---...
0
votes
0
answers
801
views
How to use setTimeout in the Method intercept() the Http Interceptor
I used HttpInterceptor to set the "bearer token" heading to log in Angular, when I log in the server returns a token and I save it in a Response variable but I need a Request variable that is why I ...
0
votes
0
answers
327
views
ionic httpclient doesnt work on emulator with net core 0 Unknown Error"
I'm getting this error, with ionic serve is working fine in the browser, but when i ran ionic cordova emulate android or ios is not working as expected, i tried to fetch another url and with another ...
3
votes
1
answer
746
views
How to add interceptors to app.module conditionally?
I read other topics but none of them reflects my problem.
Background first - we got an Angular App which works in two modes - in first mode applications uses one API and in the second one - another ...
0
votes
0
answers
319
views
Can rxjs timeout operator trigger a function instead of returning error and cancelling the http call
I'm implementing an angular interceptor service which looks for error and shows a snackbar, now I'm trying to add functionality to handle "No internet" or "Slow Internet". I tried with timeout ...
0
votes
2
answers
1k
views
Error while implementing CanDeactivate Guard
I'm currently trying to implement a CanDeactivate Guard to my angular application which already had HTTP Interceptor to resolve for authentication.
But adding the CanDeactivate guard is throwing ...
0
votes
1
answer
24
views
Chain Two request and return an object Angular 7
I have a request to search the notifications that match with an user input search, but each notifications that match have a newsId properties, I want when I got the notification from server, make ...