I will write again the use case.
I have created one custom Strapi route/api (not inside the plugin) but in Strapi itself
src/api/data
the src/api/data/routes/data.ts
export default {
routes: [
{
method: 'GET',
path: '/data',
handler: 'data.get',
config: {
policies: [],
middlewares: [],
},
},
],
};
src/api/data/controllers/data.ts
export default {
get: async (ctx, next) => {
try {
ctx.body = 'ok';
} catch (err) {
ctx.body = err;
}
},
};
In the frontend I have created a plugin that makes the calls like
const { get } = getFetchClient();
const response = await get('/api/data');
I also used request as you suggested
In both cases I get 401 response code and get logged-out from Strapi admin panel