Error http request CORS implementation

#1

Hi

I have an error with an http request.

We have implemented CORS on the server and all our transactions respond correctly except one.

This transaction sometimes responds well and sometimes does not. When it does not show up correctly, we get the message:

{“headers”:{“normalizedNames”:{},“lazyUpdate”:null,“headers”:{}},“status”:0,“statusText”:“Unknown Error”,“url”:null,“ok”:false,“name”:“HttpErrorResponse”,“message”:“Http failure response for (unknown url): 0 Unknown Error”,“error”:{“isTrusted”:true}}

The only difference I’ve noticed is that the times it responds well is when takes less time to respond.My question is.

Is there any configuration parameter in the CORS or in the http request that controls the time that is expected by the endpoint response?

Endpoint Headers
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS
Access-Control-Max-Age: 1000
Access-Control-Allow-Headers: Content-Type, X-Auth-Token , Authorization, Accept
Cache-Control: no-cache, private
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
Content-Length: 86
Content-Type: application/json

#2

Hi @jisaballo :wave:

Status code 0 usually happens when a request is made but no response is received, so there’s no status code either. It can be a CORS error (the request is blocked by the browser), the server ends the connection before responding, or a network connectivity problem.

Are you getting any CORS-related error message in the Dev Tools console? It would be a good idea to analyze the requests that are working fine and the one that doesn’t and check for differences server-side.

Best,
Rodrigo