D
D
dfv1232018-04-16 22:58:25
Node.js
dfv123, 2018-04-16 22:58:25

Why does a 403 error occur during authorization?

client: https://codesandbox.io/s/wqjrv7746k
server: https://repl.it/@be1dev/MeagerBlindTrace-1
Expected behaviour. By clicking on register, we get a token, save it in localStorage (it works), immediately the second request to read data from a closed route on the server, present the token (403).
Through Postman it works without errors.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Aleksandrovich, 2018-04-17
@dfv123

try it like this

axios({
      method: 'post',
      url: `${ROOT_URL}/posts`,
      data: {
      },
      headers: { authorization: localStorage.getItem("token") }
    })

https://codesandbox.io/s/35ov9yqrq

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question