![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | aljuarismi |
I am having problems with HttpRequest
When I reproduce my project on desktop it works ok and the value of result is 0; but when I play it in HTLM5 the result gives me 4 and does not read the data from the api.
func _on_HTTPRequest_request_completed(result, response code, headers, body):
print (result)
You should print the response_code and maybe the headers too.
And did you check the browser console output?
clemens.tolboom | 2021-07-14 20:20
Hello, thank you, you helped me solve part of the problem. Check the browser console output and it was a CORS error. I solved it by adding the lines to the htacces
Header set Access-Control-Allow-Origin "*"Now with this change, a httprequest request that previously worked fine was broken, it throws me the following error:
*Access to fetch at ‘url’ from origin ‘http://localhost:8060’ has been blocked by CORS policy: The ‘Access-Control-Allow-Origin’ header contains multiple values 'http://localhost:8060, ', but only one is allowed. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
aljuarismi | 2021-07-14 20:57
You setting looks ok to me Access-Control-Allow-Origin - HTTP | MDN
But it does ring a bell but not sure which
Maybe this apache - CORS - multiple values in Access-Control-Allow-Origin - Stack Overflow helps?
clemens.tolboom | 2021-07-15 06:55