I
I
Ibishka2020-09-22 11:15:36
PHP
Ibishka, 2020-09-22 11:15:36

Where to store React js + Rest api php tokens?

The project was divided into 2 separate projects Spa shop on react js and back on php (rest api). For authorization, etc., I use 2 jwt tokens and a resfresh token. Refresh can store localstorage, but jwt needs to be in a cookie with the http only flag, then I can’t take it from js to fetch it in the back, then where to store it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Robur, 2020-09-22
@Ibishka

fetch won't send cookies, unless you set the credentials init option. (

use the credentials option and fetch will send whatever cookies you have.
https://developer.mozilla.org/en-US/docs/Web/API/W...

D
Dmitry, 2020-09-22
@dimoff66

jwt can be stored in sessionStorage

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question