I found that React Native does not give HTTP_USER_AGENT value to Django Graphene. On Garaphene, I receive the header by:
def resolve(cls, root, info, **kwargs):
info.context.META['HTTP_USER_AGENT']
It works when I send a query through a browser. However, the HTTP_USER_AGENT only has "okhttp/3.6.0" value when I send a query through my React Native app. So I tried to change the HTTP_USER_AGENT value by setting headers of axios.
onSubmit = async () => {
if (!this.state.isSubmitting) {
this.setState({isSubmitting: true});
await axios({
url: 'http://192.168.0.6:8000/graphql/',
method: 'post',
headers: {
HTTP_USER_AGENT: 'CCC'
},
data: {
query: `
It does not work. HTTP_USER_AGENT does not change and only shows "okhttp/3.6.0". I tried other custom headers and found that they do not work either. I cannot just set my own custom-named-header. Why is this the case? The only header I was available to change was AUTHORIZATION. Django Graphene received the header value when I set
await axios({
url: 'http://192.168.0.6:8000/graphql/',
method: 'post',
headers: {
AUTHORIZATION: 'JWT CCC'
},
and the value was available from
info.context.META['HTTP_AUTHORIZATION']
I had no idea if my assumptions were wrong.