1
I’m trying to make a call GET/AJAX
for a URL
which is different from the one I’m making the call, but I always get the message in the browser:
Failed to load http://urldoserver.com/: No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://meuserver.com/' is therefore not allowed access.
I’ve tried so much on server Apache
as NGINX
and enable the CORS
according to the documentation and some tips. I even tried via PHP
add the header
:
<?php header("Access-Control-Allow-Origin: *"); ?>
But I always get the blocking message from CORS
. Via POSTMAN
the call normally occurs.
I must ask the server administrator to release the IP from my server to perform the calls or I am mistakenly configuring the CORS or the call from my side on the server?
I’d like to know, is there any way I can create a JSON API and consume it from within one of the application files?
– riki481
No problem, because the application will consume in localhost your API.
– Danilo P. da Silva
Ahhhh, in this case the URL would look like
localhost:8100
(generic localhost)?– riki481
That’s right, if your API is on port 8100 just call with that URL. Type
http://localhost:8100/alguma_rota
– Danilo P. da Silva
Thanks, you saved my TCC
– riki481