Closed DonGiulio closed 6 years ago
I also double checked back end (using Postman) and front end (using an express server) in isolation, I confirm that Postman receives the parameters from the back end, and somehow Axios doesn't receive. Here's the code of my express server:
const express = require("express");
var cors = require("cors");
const app = express();
app.use(cors());
app.post("/auth/sign_in", (req, res) => {
res.header({
"access-token": "8bpg8pp2FRKhvcScQUIgxg",
uid: "example@email.com",
client: "TBb9IT84WDuLsM5oz2FrrA",
expiry: "1519832141"
});
res.json({
data: { errors: { email: "wrong", password: "ugly" } }
});
});
app.listen(5000, () => console.log("Example app listening on port 5000!"));
I seem to have figured it out, it wasn't a problem with the client, the CORS configuration needed to explicitly expose the extra headers with:
expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'],
You, sir, are awesome. Just calling this out in case it helps anyone else
@DonGiulio what was your devise_token_auth
config? I'm getting similar errors where I can POST
to devise_auth_token
using j-token
but cannot via redux-token-auth
I'm trying to setup token auth with
devise_token_auth
andredux-token-auth
,I'm finding troubles in getting the tokens to the client.
I've traced everything down to this axios call, which supposedly retrieves the headers and persists them in storage with
persistAuthHeadersInLocalStorage
.I traced the response in my browser, and here is the response headers:
and the response body is:
I added some logging to the response in the form of:
and this the response object I get is this:
no traces of several headers, especially the
access-token
one which is the one I need for the token authorisation.any clues where that would be?