I have server that accept only http (no https). And when I call an api, axios automatically change http to https.
I create axios instance here:
JavaScript
x
4
1
export const axiosAgent = axios.create({
2
baseURL: "http://xxx.xxx.xxx/api/v1/",
3
});
4
But in browser http changes to https, so it become: https://xxx.xxx.xxx/api/v1/all
and I get net::ERR_NAME_NOT_RESOLVED
How can I prevent that?
UPDATE Request Header:
JavaScript
1
6
1
Provisional headers are shown
2
Accept: application/json, text/plain, */*
3
Access-Control-Allow-Origin: *
4
Referer: http://localhost:3000/patients
5
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
6
and there is no response header.
and now I get net::ERR_SSL_PROTOCOL_ERROR
Advertisement
Answer
I just remove <meta http-equiv="Content-Security-Policy" content="default-src 'self'">
from head in html. and problem solved.
This meta tag change all http request to https one, so this is not related to axios.