Why i cant redirect to external url when handle specific path in Strapi

29 views Asked by At
import { SSOService } from '../services/sso.service';
import { RoutePrefixes } from '../../types';
import { Context } from 'koa';

export default (_config: any, { strapi }: any) => {
  return async (ctx: Context, next: () => any) => {
    const service: SSOService = new SSOService(strapi, ctx);

    if (!ctx.request.url.startsWith(RoutePrefixes.ADMIN)) {
      await next();
      return;
    }

    if (ctx.request.url.startsWith(RoutePrefixes.LOGOUT)) {
      ctx.redirect("some-url")
      return;
    }

    await service.redirect();

    await next();
  };
};

Something strange is happening, or I don’t understand something

I need to redirect the user to the main application page (outside strapi) via an external link after he logs out I processed the path /admin/logout so that after that it would be redirected, but this does not work and koa just sends a GET request returning code 200, but outside of the condition I have another method (service.redirect) that does the same thing, it also has the redirect logic through ctx.redirect, but it only works when the page is restarted how can I do the redirect correctly?

0

There are 0 answers