Closed jablonski closed 1 month ago
One addition to this: another typical use-case that fails now is when doing unit testing. At least I haven't found a useful way to specify a port when running in unit test environments using app.inject
to query certain endpoints. This also has the same effect as described above, the path is not parsed correctly.
Prerequisites
Fastify version
5.0.0
Plugin version
6.0.0
Node.js version
20
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Unknown
Description
When running Fastify with fastify-url-data on Vercel or Railway with Fastify 4, all works fine.
Running with Fastify 5, the "path" contains a leading "null/...", so the application breaks.
I suspect the following change for the problem:
Former plugin code was:
The current code of the plugin was changed to:
I suspect that "port" is "null" when deploying on Vercel or Railway, therefere the fastUri-parser "fails".
The following example shows the problem:
It prints "null/todos".
Link to code that reproduces the bug
https://github.com/jablonski/fastify-serverless-function
Deployed on Vercel:
https://fastify-serverless-function-gules-ten.vercel.app/foo/bar
Here's the version deployed with fastify@4.28.1 and fastify-url-data@5.4.0, which works fine:
https://fastify-serverless-function-git-fastify-4-jeasx.vercel.app/foo/bar
Expected Behavior
When no port is set, the code should omit the port definition, so the path-Attribute doesn't starts with "null/".