500 error from server functions when using getRequestHeaders in production with Bun
I have a separate API and am using server functions to proxy requests that need headers like so:
This works fine locally, but when deploying it to my VPS (using coolify), all calls are coming back with a 500 status code. Some requests also say "Only HTML requests are supported here". I saw someone else's question and it seems they had a rewrite in their AWS config, but I don't see anything that could be causing this in my setup (perhaps coolify is doing something weird behind the scenes)
When I don't include getRequestHeaders() I do get back other status codes like 401 though, but the 500 errors definitely are not coming from the API.
I'm on version 1.132.51. I've tried deploying with Nitro v3, v2, and the custom bun server file.
Anyone have any idea why this might be happening?
1 Reply
foreign-sapphireOP•18h ago
For anyone else running into this, using the "node-server" preset for Nitro and using node to start the server fixed the issue.
You can do this while still using Bun for local dev and building.
Not sure why bun fails to make requests with headers from server functions. Could be something with Coolify's settings or Nixpacks. If time allows I'll try deploying with a custom dockerfile to see if it changes anything.