Axios don't set up default headers

45 Views Asked by At

Hello everyone!

Yesterday I faced with issue, in order to omit some warning from ngrok, I have to add additional header to get my data from db. Error message I use axios to make a request to api and I also use ngrok as free host, to up my frontend and fake-api (json-server). I found a solution here: Can not remove ERR_NGROK_6024 when using Shopify App Proxy get call But now when I add this header to my request next way:

const result = await axios.get(
   `${BASE_API_URL}/db`,
    {
        headers: {
            "ngrok-skip-browser-warning": 69420
        }
}
                
     );

All default headers are deleting: Headers with additional header

And as you can see all my default headers disappeared

If I make normal request without additional header:

const result = await axios.get(`${BASE_API_URL}/db`);

All default headers appear there next way: Headers without additional header But in order to fix my issue I have to add this header, I can't get why when I add additional header axios delete all other default headers at all?

I tried to set up default headers next way:

queryFn: async () => {
            axios.defaults.headers["ngrok-skip-browser-warning"] = 69420;
            const result = await axios.get(`${BASE_API_URL}/db`);
            return result.data as DashBoard;
        },

I still get the same problem, that axios don't set up default headers I followed by this guide from original axios documentation: https://axios-http.com/docs/config_defaults

0

There are 0 best solutions below