I am making a GET request to my local web service, which I expect the 302 response to be returned with the location in the header. However, I get a response from undefined and a network error, although I can see locally that the request is being served and the response is generated without any errors in the web service.
I tried in Postman and Chrome and it gets a redirect response and redirects accordingly.
I'm not sure if this is a CORS problem, and if so, how can I solve this?
I already added a response header for the CORS filter
Access-Control-Expose-Headers: Location, [own headers] Access-Control-Allow-Origin: '*' Access-Control-Allow-Methods: POST, PUT, GET, OPTIONS, DELETE Access-Control-Max-Age: [some age] Access-Control-Allow-Headers: [own headers]
And the location is present in the header when I use Postman
A request created using Axios and config,
const config = { url: [someURL], method: 'GET', headers: { 'customHeader':'token', }, params: { [params] }, maxRedirects: 0, validateStatus: status => (status >= 200 && status < 300) || status === 302, };
Any help would really be appreciated as to why the answer is undefined when it reaches my JS code but works fine in Postman and Chrome.
How can I solve this is to use the HTTP 200 status code and redirect the location header, but I want to avoid this because it is technically a redirect response.