I have an angular js client that makes requests to a server. My http
provider (at http://localhost) code looks like this:
angular.config(['$httpProvider', function ($httpProvider) {
// Reset headers to avoid OPTIONS request:
$httpProvider.defaults.headers.common = {};
$httpProvider.defaults.headers.post = {};
$httpProvider.defaults.headers.put = {};
$httpProvider.defaults.headers.patch = {};
$httpProvider.defaults.withCredentials = true;
}]);
At the server side (at http://localhost:3000 , so just the port is
different), I return the headers back with a perl script in Mojolicious
like this:
# Set response headers so that we can send cross-domain requests
$self->res->headers->header('Access-Control-Allow-Origin' =>
$self->req->headers->header('origin'));
$self->res->headers->header('Access-Control-Allow-Credentials' =>
'true');
$self->res->headers->header('Access-Control-Allow-Methods' => 'GET,
POST, OPTIONS');
$self->res->headers->header('Access-Control-Allow-Headers' =>
'Content-Type, X-CSRF-Token');
$self->res->headers->header('Access-Control-Max-Age' =>
'1728000');
Now, this code works perfectly in Angular 1.2. However, when I try to
upgrade to Angular 1.5, things stop working. When looking at my logs and
firebug, the server is accessed, the right scripts are executed, the server
returns the correct values, the browser (tested with both firefox and
chrome) simply ignores everything that is sent back, including any error
codes. The problem seems to happen with Angular 1.4 as well.
Did something change in the meantime with Angular? Is there some extra code
that needs to be run for it to accept Cross-Domain requests?
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.