Skip to content

JSONP request will always failed if HttpClientJsonpModule imported after HttpClientModule #47312

@laggage

Description

@laggage

Which @angular/* package(s) are the source of the bug?

common/http

Is this a regression?

Yes

Description

After update to angular14, a function in our project which use HttpClient.jsonp() not work any more.

We finded out that HttpClient.jsonp in v14 will throw an error if the headers in reqeust is not empty, and that what make matters worse is that in the project we import HttpClientModule which provides a HttpXsrfInterceptor before HttpClientJsonpModule, so before JsonpInterceptor can handle the jsonp request, the request was already intercepted by HttpXsrfInterceptor and a xsrf header was already added to the request which caused the 'JSONP requests do not support headers' Error

I don't think is resonable that we must import HttpClientJsonpModule before HttpClientModule to use jsonp. May be HttpXsrfInterceptor should escape if request.method is jsonp, i'd like to help if angular team agree with this.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

JSONP requests do not support headers

Please provide the environment you discovered this bug in (run ng version)

angular v14
node v16
macos 12.5.1

Anything else?

No response

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: common/httpIssues related to HTTP and HTTP Client

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions