You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat($http): JSONP requests now require a trusted resource URL
The $http service will reject JSONP requests that are not trusted by
`$sce` as "ResourceUrl".
This change makes is easier for developers to see clearly where in their
code they are making JSONP calls that may be to untrusted endpoings and
forces them to think about how these URLs are generated.
Be aware that this commit does not put any constraint on the parameters
that will be appended to the URL. Developers should be mindful of what
parameters can be attached and how they are generated.
Closesangular#11352
BREAKING CHANGE
All JSONP requests now require the URL to be trusted as resource URLs.
There are two approaches to trust a URL:
**Whitelisting with the `$sceDelegateProvider.resourceUrlWhitelist()`
method.**
You configure this list in a module configuration block:
```
appModule.config(['$sceDelegateProvider', function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhiteList([
// Allow same origin resource loads.
'self',
// Allow JSONP calls that match this pattern
'https://some.dataserver.com/**.jsonp?**`
]);
}]);
```
**Explicitly trusting the URL via the `$sce.trustAsResourceUrl(url)`
method**
You can pass a trusted object instead of a string as a URL to the `$http`
service:
```
var promise = $http.jsonp($sce.trustAsResourceUrl(url));
```
Copy file name to clipboardExpand all lines: docs/content/error/$http/badreq.ngdoc
+5-1
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,11 @@
3
3
@fullName Bad Request Configuration
4
4
@description
5
5
6
-
This error occurs when the request configuration parameter passed to the {@link ng.$http `$http`} service is not an object. `$http` expects a single parameter, the request configuration object, but received a parameter that was not an object. The error message should provide additional context such as the actual value of the parameter that was received. If you passed a string parameter, perhaps you meant to call one of the shorthand methods on `$http` such as `$http.get(…)`, etc.
6
+
This error occurs when the request configuration parameter passed to the {@link ng.$http `$http`} service is not a valid object.
7
+
`$http` expects a single parameter, the request configuration object, but received a parameter that was not an object or did not contain valid properties.
8
+
9
+
The error message should provide additional context such as the actual value of the parameter that was received.
10
+
If you passed a string parameter, perhaps you meant to call one of the shorthand methods on `$http` such as `$http.get(…)`, etc.
7
11
8
12
To resolve this error, make sure you pass a valid request configuration object to `$http`.
0 commit comments