Avoiding to hard code API request prefix

This commit is contained in:
marcoautiero 2025-05-05 10:29:05 +02:00
parent d65f67e0c5
commit 5ca82b4c83

View File

@ -18,10 +18,10 @@ const createMiddleware = ({ sendEvent }: { sendEvent: Sender }) => {
const middleware: Core.MiddlewareHandler = async (ctx, next) => {
const { url, method } = ctx.request;
const apiPrefix = strapi.config.get('api.rest.prefix', '/api');
if (
!url.includes('.') &&
url.includes('/api') &&
url.includes(apiPrefix) &&
['GET', 'PUT', 'POST', 'DELETE'].includes(method)
) {
if (Date.now() > state.expires) {