Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal req.headers on firebase environment #3035

Open
vis97c opened this issue Jan 24, 2025 · 1 comment
Open

Minimal req.headers on firebase environment #3035

vis97c opened this issue Jan 24, 2025 · 1 comment

Comments

@vis97c
Copy link

vis97c commented Jan 24, 2025

Environment

  • Operating System: Windows_NT
  • Node Version: v18.20.4
  • Nuxt Version: 3.14.1592
  • CLI Version: 3.15.0
  • Nitro Version: 2.10.4
  • Package Manager: yarn@4.2.2
  • Builder: -
  • User Config: default
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/~/github.com/vis97c/nitro-firebase-host
https://github.com/vis97c/nitro-firebase-host

Describe the bug

In a firebase project (nitro preset: firebase) try to log headers.host or x-forwarded-host. The expected result should be the original request host but instead we get "localhost"

Additional context

A firebase project with admin sdk is required

Logs

Google clouds prints the following for console.log(event.node.res.req.headers)

{
  'cache-control': 'public, max-age=120, stale-while-revalidate=60',
  host: 'localhost'
}
@vis97c
Copy link
Author

vis97c commented Feb 16, 2025

For added context, I was making a request for validation from a global route middleware. On the client side all the headers where passed but on server side only the explicit headers (cache-control) where present.

As an alternative capture the request event on the middleware and send the headers.

// middleware/instance.global.ts
const event = useRequestEvent();
const headers = event?.node.req.headers

return $fetch("/api/instance", { headers });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant