#How do I get an header forwarded by nginx?
15 messages · Page 1 of 1 (latest)
Do you mean something like this? https://nuxt.com/docs/getting-started/data-fetching#pass-cookies-from-server-side-api-calls-on-ssr-response
not from an internal request, I want to get the headers of the browser request for the webpage, you know?
If you need to pass headers from client to server, the same page has an example as well: https://nuxt.com/docs/getting-started/data-fetching#pass-client-headers-to-the-api
I have this but something is still wrong:
const { data } = await useFetch('http://ip-api.com/json/' + useRequestHeaders(['X-Real-IP']) + '?fields=49393')
I tried this method before and it did not work
Have you tried to add the correct headers to the useFetch?
const { data } = await useFetch('http://ip-api.com/json/?fields=49393', {
headers: {
'X-Real-I': '...'
}
});
I don't want to send this header, I want to get the header
I may have explained this wrong
basicially I just need to get the ip adress of the visitor (of my page)
to then display the location
Then it seems you want to pass headers from client to server. Yes, the doc shows how to pass cookies but you could use any header component you need.
https://nuxt.com/docs/getting-started/data-fetching#pass-client-headers-to-the-api
oh I finally got it
how would I print just the value of the useRequestHeaders(...)?
like only the header value, without name and stuff