where to store jwt tokens with angular

Discussão em 'Angular' iniciado por Azedine BAKA, Abril 13, 2025.

  1. Azedine BAKA

    Azedine BAKA Guest

    i have a web app and im using JWT token to identify users, for the moment im savng the token within the state using ngrx like this:

    export const authReducer = createReducer(
    initialAuthState,
    on(LoginSuccess, LoginSuccessNotEnabled, ValidationSuccess, LoginSuccessNotSetUp, (state, action) => ({
    ...state,
    isLoggedIn: true,
    token: action.token
    }))
    );


    but since the state gets lost when reloading pages, what is a more durable way of storing said token. i see localStorage floating around but that is exposed to XSS, and cookies are cumbersome since my backend is set to verify auth headers and not cookies.

    Continue reading...

Compartilhe esta Página