Hey, Kapa is dead
Iβm trying to add a global middleware to my plugin in typescript but I canβt manage to set it up. I receive 404 response on all requests and console.log('Middleware');
(see under) is never logged
My middleware in src/plugins/myplugin/server/middlewares/redirect.ts
export default () => async (ctx, next) => {
console.log('Middleware');
await next();
};
};
I registered it in `src/plugins/myplugin/server/register.ts``
...
strapi.server.use(middlewares.redirect)
And I also added it to my config/middleware.ts
file since it is a global middleware.
export default [
'strapi::logger',
'strapi::errors',
'plugin::myplugin.redirect',
'strapi::cors',
...
Did I miss something ?
I did not find any documentation for writing middlewares in typescript, nor any example in existing plugins.
This topic has been created from a Discord post (1240319511857463429) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord