I
I
Ibishka2020-09-22 20:54:29
PHP
Ibishka, 2020-09-22 20:54:29

Why doesn't Axios send a Cookie?

My React js SPA is at localhost:3000 backed by api.f-mania (rest api php).
In React js I use axios credentials inserted true:

axios.interceptors.request.use((config) => {
      config.withCredentials = true;
      return config;
    });

put in back:
// Headers
header('Access-Control-Allow-Origin: http://localhost:3000');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
header('Access-Control-Allow-Headers: *');
header('Content-Type: application/json');

I execute a GET request in the back, but the cookie is not sent, although there is a cookie in the SPA.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question