enniob
January 18, 2024, 1:34pm
1
I’m using the tyk-gateway v5.2.2 Open Source edition on docker, but I’m getting the following error when I add a JavaScript Middleware.
level=error msg=“Your API specifies a CP custom middleware, either Tyk wasn’t build with CP support or CP is not enabled in your Tyk configuration file!” prefix=coprocess
on my tyk.conf I have the following setup
....
"tyk_js_path": "/opt/tyk-gateway/js/tyk.js",
"middleware_path": "/opt/tyk-gateway/middleware",
"enable_jsvm": true,
...
and on my app/appname.json configuration I have the following
...
"custom_middleware": {
"pre": [
{
"name": "TokenValidationMiddleware",
"path": "/opt/tyk-gateway/middleware/auth.js",
"require_session": false
}
]
},
...
Is there any other configuration I need to add to make the middleware work on the OSS version?
thank you,
Ennio
enniob
January 18, 2024, 7:20pm
2
I made some changes on how it is setup and now I see the following error on my log
2024-01-18 14:12:43 time="Jan 18 19:12:43" level=debug msg="Registering coprocess middleware, hook name: myAuthhook type: Pre, driver: " api_id=api_test api_name=Api_test org_id=1 prefix=coprocess
2024-01-18 14:12:43 time="Jan 18 19:12:43" level=error msg="Unsupported driver ''javascript" prefix=coprocess
"custom_middleware": {
"pre": [
{
"name": "myAuth",
"path": "middleware/myAuth.js",
"require_session": false
}
],
"post": [],
"post_key_auth": [],
"auth_check": [],
"response": [],
"id_extractor": {
"extract_from": "header",
"extract_with": "Authorization",
"extractor_config": {
"header_name": "Authorization"
}
}
},
SO I cannot use custom_middleware with the OSS version? I’m working on a prototype and want to make it will do what we are looking for.
Thanks
Olu
January 24, 2024, 11:00am
3
Welcome to the community
You seem to be missing the driver
property. This is now a mandatory field as on previous versions leaving it empty would default to otto
"driver": "otto"
For more information about plugin drivers please visit our doc