Skip to content

Buid React JWT Refresh Token example with Axios Interceptors - Refresh Token in React.js, Axios silent refresh JWT token example

Notifications You must be signed in to change notification settings

bezkoder/react-jwt-refresh-token

Repository files navigation

React Refresh Token with JWT and Axios Interceptors example

react-refresh-token-jwt-axios-interceptors-flow

For more detail, please visit:

React Refresh Token with JWT and Axios Interceptors

React JWT Authentication & Authorization example

Fullstack (JWT Authentication & Authorization example):

React + Spring Boot

React + Node.js Express

This project was bootstrapped with Create React App.

Set port

.env

PORT=8081

Note:

Open src/services/api.js and modify config.headers for appropriate back-end (found in the tutorial).

instance.interceptors.request.use(
  (config) => {
    const token = TokenService.getLocalAccessToken();
    if (token) {
      // config.headers["Authorization"] = 'Bearer ' + token;  // for Spring Boot back-end
      config.headers["x-access-token"] = token; // for Node.js Express back-end
    }
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);

Project setup

In the project directory, you can run:

npm install
# or
yarn install

or

Compiles and hot-reloads for development

npm start
# or
yarn start

Open http://localhost:8081 to view it in the browser.

The page will reload if you make edits.

Related Posts

In-depth Introduction to JWT-JSON Web Token

React.js CRUD example to consume Web API

React Pagination example

React File Upload with Axios and Progress Bar to Rest API

Fullstack (JWT Authentication & Authorization example):

React + Spring Boot

React + Node.js Express

CRUD with Node.js Express:

React.js + Node.js Express + MySQL

React.js + Node.js Express + PostgreSQL

React.js + Node.js Express + MongoDB

CRUD with Spring Boot:

React.js + Spring Boot + MySQL

React.js + Spring Boot + PostgreSQL

React.js + Spring Boot + MongoDB

CRUD with Django:

React.js + Django Rest Framework

Serverless:

React Firebase CRUD App with Realtime Database

React Firestore CRUD App example | Firebase Cloud Firestore

Integration (run back-end & front-end on same server/port)

Integrate React with Spring Boot

Integrate React with Node.js Express

About

Buid React JWT Refresh Token example with Axios Interceptors - Refresh Token in React.js, Axios silent refresh JWT token example

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published