In Strapi v4, I tried to setup discord oath provider following the latest-docs. I've setup the keys and everything but when I try to hit /api/connect/discord
I'm getting this error
Grant: mount session middleware first
I goggled a bit and found that Strapi need to use grant as a middleware first in order to use it. so I checked /config/middleware.js
module.exports = [
'strapi::errors',
'strapi::security',
'strapi::cors',
'strapi::poweredBy',
'strapi::logger',
'strapi::query',
'strapi::body',
'strapi::favicon',
'strapi::public',
];
it was missing grant so I tried creating a custom global grant middleware but I need to get hold of the app instance and do the following
app.use(session({secret:'grant'));
app.use(grant);
how can I achieve this? or if anyone has any idea to fix the above problem ?
I had exactly the same concern for the integration of twitch.
The only solution I have found for the moment is to do this, but I hope that there will be a fix in the next update because suddenly we are dependent on the koa-session2 library.
https://github.com/Secbone/koa-session2
'use strict';
const session = require("koa-session2");
module.exports = {
/**
* An asynchronous register function that runs before
* your application is initialized.
*
* This gives you an opportunity to extend code.
*/
register({ strapi }) {
strapi.server.use(session({
secret: "grant",
}));
},
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*/
bootstrap(/*{ strapi }*/) { },
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With