Fuel: Fail to pass request header `Origin`

Created on 25 Dec 2019  路  8Comments  路  Source: kittinunf/fuel

Issue Report

Description

  • Set header Origin in request, but no value found on server-side
  • Fuel version: 2.1.0
client
                .post(path = ENDPOINT_OAUTH, parameters = listOf("grant_type" to "client_credentials"))
                .authentication()
                .basic(username = apiUsername(), password = apiPassword())
                .header(Headers.CONTENT_TYPE, APPLICATION_FORM_URLENCODED)
                .header(Headers.ACCEPT, APPLICATION_JSON)
                .header("Origin", "http://xxx")

Expected behavior

http request header Origin should be passed

bug

Most helpful comment

That is exactly what I expected.

This also means that _fuel_ can not fix this. But you can follow the steps to allow restricted headers. Thanks @ryutoyasugi .

All 8 comments

Are you certain it's not _sent_ and not just (lack of) CORS settings on the server?

Hi @SleeplessByte , thanks for your reply!
I have tested it:

  • it works well when using curl, Postman or invoking from other services (like nodejs).
  • I changed to allow "*" for "Access-Control-Allow-Origin" and "Access-Control-Allow-Headers", and this couldn't fix the issue - the header value origin can not be passed into server
  • I am sure the Origin value has been sent to com.github.kittinunf.fuel.toolbox.HttpClient (debuging screenshot will be attached)
  • I tested with with other dummy headers, all passed in. Looks like only "origin" doesn't work

Selection_005

Thank you very much! That is very helpful :)

cool thanks

That is exactly what I expected.

This also means that _fuel_ can not fix this. But you can follow the steps to allow restricted headers. Thanks @ryutoyasugi .

Thanks guys! Yeah, a quick fix is System.setProperty("sun.net.http.allowRestrictedHeaders", "true"); or -Dsun.net.http.allowRestrictedHeaders=true

Is there anything from us (Fuel side) to help users? Should we create an FAQs or something?

Was this page helpful?
0 / 5 - 0 ratings