-
Hi everyone I was wondering if someone could help with my react code in order to make my axios requests work. What I'm experiencing is that by doing this simple request: (my_laptop_ip, public_ip, internal_ip and internal_port are name like this for privacy) The axios call is this: try {
const resp = await axios.get(
`http://${public_ip}/api/auth/types`
);
} catch (err) {
console.log(err);
} The nginx configuration file is this:
In the backend cors is well setted and also the header Curl response: ❯ curl -vvvv -H "Origin: my_laptop_ip" http://public_ip/api/auth/types
* Trying public_ip:80...
* Connected to public_ip (public_ip) port 80 (#0)
> GET /api/auth/types HTTP/1.1
> Host: public_ip
> User-Agent: curl/7.88.1
> Accept: */*
> Origin: my_laptop_ip
>
< HTTP/1.1 200 OK
< Server: nginx/1.25.1
< Date: Tue, 11 Jul 2023 09:27:16 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 30
< Connection: keep-alive
< X-Powered-By: Express
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Origin: my_laptop_ip
< Vary: Origin
< ETag: W/"1e-D6ccC1T1C08e2aWxt7+sjhZBEkg"
<
[
"value2",
"value1"
* Connection #0 to host public_ip left intact
]% |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Solved, it was a problem with the Origin header not sended by the nginx by default. |
Beta Was this translation helpful? Give feedback.
Solved, it was a problem with the Origin header not sended by the nginx by default.