I'm currently deploying a basic API to my live server and I'm running into (what I think is) a CORS problem but there is some behavior going on that I can't explain.
I'm communicating from an AngularJS front-end to a Laravel 5 (+ laravel-cors) back-end.
I started testing with a simple jQuery AJAX call (below) and when I make a request from my local Vagrant environment (http://ift.tt/1KElwmC
) to http://ift.tt/1JKQNz1
I get an error about Access-Control-Allow-Origin
. The weird thing is that the request does come through because the information is stored in the database via the Laravel-based API correctly.
$.ajax({
method: 'POST',
url: 'http://ift.tt/1KElwCW',
data: {
"username": "username",
"first_name": "First",
"last_name": "Last",
"nickname": ""
}
}).always(function(r) {
console.log(r);
});
Error:
XMLHttpRequest cannot load http://ift.tt/1KElwCW. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://ift.tt/1JKQNz5' is therefore not allowed access.
The console.log(r)
returns {readyState: 0, responseJSON: undefined, status: 0, statusText: "error"}
I developed the application locally using a Homestead VM (API) and a Vagrant environment (application) and it's working correctly within these environments...
Some observations:
- Each of these requests shows up with Method:
POST
, Status:200 OK
, Type:xhr
in my Chrome Developer Tools. - Tools like Postman and PhpStorm's RESTful service tester correctly execute the request and the data is added without errors.
Any ideas on how to further debug this problem are welcome... I've been trying to wrap my head around this for the entire day now and I just don't know what's causing it.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1KEluec
via IFTTT
Aucun commentaire:
Enregistrer un commentaire