Why is config.proxy ignored when making an axios request within a webpack project?

Clash Royale CLAN TAG#URR8PPP
Why is config.proxy ignored when making an axios request within a webpack project?
I want to perform a request with axios@0.18.0 using an http proxy fully efficient (squid). My project is a vue project based on the webpack template. vue init webpack proxytest
vue init webpack proxytest
When I try to perform the request, axios 'ignores' the proxy property inside the config object passed.
I noticed that when I run the exact same code with pure nodejs, everything works just perfectly fine.
Is there some configuration that I need to specify excepting the axios request configuration when using axios as a npm module within webpack ?
import axios from 'axios';
const config =
proxy:
host: 'host',
port: 3128,
,
method: 'GET',
;
axios('http://www.bbc.com/', config).then((res) =>
console.log(res);
).catch((err) =>
console.error(err);
);
Of course, when testing, I change 'host' into the proxy IP.
I tried to change the method property to POST in order to check if axios considered the config. It does consider the config passed.
I tried to put a fake port so I could check if the proxy property was considered. It's not considered.
output...
Now, I'm aware of what CORS is. The point is I'm constently getting this output when performing the requests. And if the proxy was used by axios, I think no CORS "error" would show up as my proxy is a VPS.
Thank you.
1 Answer
1
You need to configure your server to receive the requests and then test. This does not seem to have anything to do with the webpack, because in your mistake, for example, you make a request for the BBC from localhost and it is very likely that you are making that mistake. So it's important to test with your server by running Front and Back locally.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
the problem is cors, and who controls cors is the server. This has nothing to do with vpn nor webpack.
– PlayMa256
Aug 10 at 0:17