Branch based redirects not working

Site name: sinom-app
I’m trying to add redirects that are based on branch. For production we want to use just an api.domain but for development and staging we want to use staging.api.domain. I don’t think that I can do that with just plain _redirects folder so I changed it and tried writing redirects plugin, but it doesn’t work and I don’t get why.
code

export const onPreBuild = function ({ netlifyConfig }) {
  // eslint-disable-next-line no-undef
  const branch = process.env.BRANCH;
  const isProduction = branch === 'master';
  const prefix = isProduction ? '' : 'staging.';

  netlifyConfig.redirects.push({
    from: '/graphql/*',
    to: `https://${prefix}api.sinom.se/graphql/:splat`,
    status: 200,
    force: true,
  });

  netlifyConfig.redirects.push({
    from: '/images/*',
    to: `https://${prefix}api.sinom.se/images/:splat`,
    status: 200,
    force: true,
  });
};

While building I get this info


But then when I access the staging.app.sinom.se all requests go to staging.app.sinom.se instead of API and I get 404 errors.

Based on the ticket in the helpdesk, this appears to be resolved.