Lack of support with Fastify 4.x
aureliendepeyrelongue opened this issue · 4 comments
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.6
Plugin version
7.0.0
Node.js version
16.14.2
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
Mac OS Monterey 12.6
Description
I have an error while trying to use fastify cors with Typescript :
"message":"fastify-plugin: fastify-cors - expected '3.x' fastify version, '4.6.0' is installed","stack":"FastifyError: fastify-plugin: fastify-cors - expected '3.x' fastify version, '4.6.0' is installed
Thanks for the help
Steps to Reproduce
Install Fastify 4.x version and last fastify cors version and try to run your server.
Expected Behavior
No response
use "@fastify/cors"
Thanks for your answer, i was already using "@fastify/cors" for the import.
On my server.ts file i have : import fastifyCors from "@fastify/cors";
I found a working solution using the Fastify adapter for Express plugins, and the CORS middleware of Express.
By the way Fastify is a beautiful framework, thanks for your work.
regards
@aureliendepeyrelongue judging by your error, you were importing old dependency, as plugin name was wrong. See:
module.exports = fp(fastifyCors, { fastify: '4.x', name: '@fastify/cors'})
express plugin via adapter will cause extra performance overhead. I strongly recommend you rechecking with proper version and correct import
Thanks for your help it worked i am now on "@fastify/cors": "^8.1.0"
and everything is ok.
Sorry for the inconvenience, and thanks for your reactivity.