即使在设置了API密钥和用户名到我的请求头后,我仍然收到错误的CSRF

I’m trying to make a POST request and I’ve set the headers for it and the content but it doesn’t get me the right result:

export default async function postNewTopic(req, res) {

    axios.post(`url/posts.json?title="${req.query.title}"&raw=${req.query.content}&category=1`, {

    headers: {

      "Api-Key":  token ,

      "Api-Username": {My key}

    }})

    .then(function (response) {

      res.json(response.data);

    })

    .catch(function (error) {

      const err = error?.response?.data || error;

      res.status(error.status ||  error.statusCode || +error.code || 500).json(err)

    })

}

And here is my frontend code:

const createTopic = () => {

    axios.post(`api/post-new?title=${title}&raw=${content}&category=1`, {

        headers: {

          "Authorization": 'Bearer' + "",

          "Api-Key":  token ,

          "Api-Username": ""

        }})

    .then(function (response) {

      res.json(response.data);

    })

    .catch(function (error) {

      const err = error?.response?.data || error;

      console.log(error.response.data)

    })

  }

You api key should be the API key and the username should be the username. It looks like you’re sending the API key as the username?

No, no it is just in the example which i deleted it. But i’ve put the api key and the api username, the gets functions are working