The problem of adding request headers to axios

  1. backstage asked me to add a request header to determine whether it is an ajax request x-requested-with = XMLHttpRequest
  2. I have tested in postman that you can get the data

    clipboard.png

  3. axiosproxyTable


    main.js


clipboard.png

after adding the request header.

May.23,2021

set headers. directly using axios.create,


API<br>main.js

Axios.defaults.headers.common['key'] = 'value';

it is our background that restricts my request. The background needs to add a parameter that allows me to add the request header

("Access-Control-Allow-Headers","key");
Menu