loopbackjs - AngularJS getting status code 0 for 413 (Request Entity Too Large) in Loopback API -


1. info

i have angularjs 1.3.15 client-side app making requests loopback api.

in app, intercept request results (with $httpprovider.interceptors) , interpret status codes display meaningful messages when user - example intercept 401 responses telling user doesn't have authorization, 200 when saves , on.

2. problem

for example if user tries upload image that's big, request payload exceed remoting limit , able intercept requesterror status code shows 0. looking @ browser's console see this:

put http://localhost:3000/api/modules?id=9 413 (request entity large) xmlhttprequest cannot load http://localhost:3000/api/modules?id=9. no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost' therefore not allowed access. response had http status code 413. 

the problem if server offline, status code 0 when intercepting requesterror, there's no way me distinguish error connecting server between error sending data.

is there chance there's issue express router middleware? can't seem find that's having same problem...

i had same issue, problem not produced angularjs. problem hint is:

 no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost' therefore not allowed access. 

because cors not configured component throw 413 error, angularjs not correct status code. had enable cors in case in backend before nodejs -> express -> bodyparser initiated , problem gone.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -