0

I have an application made with React on GAE protected by IAP.
I would like to show the logged in user's email address on the app page.
According to the documentation, there is a header named "x-goog-iap-jwt-assertion" that includes identified user information in the request header.
I successfully retrieved the request header in Nodejs with Express, but couldn't retrieve this request header data in React.

Is there a way to retrieve this request header data in React?


UPDATE

i have tried axios.get("/").then(res => console.log(res.headers));

and it returns

{
  "alt-svc": "h3-27=\":443\"; ma=2592000, h3-25=\":443\"; ma=2592000, h3-T050=\":443\"; ma=2592000, h3-Q050=\":443\"; ma=2592000, h3-Q049=\":443\"; ma=2592000, h3-Q048=\":443\"; ma=2592000, h3-Q046=\":443\"; ma=2592000, h3-Q043=\":443\"; ma=2592000",
  "cache-control": "no-cache, must-revalidate",
  "content-encoding": "gzip",
  "content-type": "text/html",
  "date": "Mon, 08 Jun 2020 08:02:21 GMT",
  "etag": "\"AdbtXg\"",
  "expires": "Fri, 01 Jan 1990 00:00:00 GMT",
  "pragma": "no-cache",
  "server": "Google Frontend",
  "x-cloud-trace-context": "c6266644decdc531641c3f57a99ef645",
  "x-firefox-spdy": "h2"
}
qasimalbaqali
  • 2,079
  • 24
  • 51
aaaa
  • 1
  • 1
  • What library are using to make the request with? – qasimalbaqali Jun 08 '20 at 14:07
  • i tried with axios and request – aaaa Jun 08 '20 at 16:31
  • could you please share the code that you have tried, and the print of the headers that you receive in the response of the request? Example: `axios.get('http://google.com').then((resp) => { console.log(resp.headers) })` – qasimalbaqali Jun 08 '20 at 18:03
  • That was too long so i edited my post and pasted. However I think axios returns only response data not request data. – aaaa Jun 09 '20 at 01:19
  • I tested to retrieve the request header with Nextjs(SSR) and succeeded. So I have decided to remake App with Nextjs. – aaaa Jun 09 '20 at 07:27

0 Answers0