Strapi 5: Custom Login page - Stack Overflow

I'm migrating from Strapi 4 to Strapi 5 and need to override the default login page in production.

I'm migrating from Strapi 4 to Strapi 5 and need to override the default login page in production. In Strapi 4, I successfully replaced the default login component by using webpack’s NormalModuleReplacementPlugin to redirect users to my custom login component.

In Strapi 5, however, despite providing my custom login component (which I placed in the expected directory), users are always redirected to the default login screen. (To be clear, I’m not referring to just modifying the welcome page or the login logo—I want the entire login component to be replaced with my custom one.)

Has anyone managed to override the default login page in production in Strapi 5? What steps or configurations are needed to ensure that my custom login component is used instead of the default one?

Any insights or updated approaches (especially with Vite now being used for the admin build) would be greatly appreciated!

StrapiProject/src/admin/webpack.config.js:

"use strict";
const path = require("path");
const webpack = require('webpack');
const strapiCacheSrcPath = path.resolve(__dirname, "../../.cache/admin/src/pages/AuthPage/components/Login");
/* eslint-disable no-unused-vars */
module.exports = (config) => {
  if (process.env.NODE_ENV === "production") {
    config.plugins.push(
      new webpack.NormalModuleReplacementPlugin(
        /admin\/src\/pages\/AuthPage\/components\/Login\/(.*).js/,
        (resource) => {
          if (resource.createData.resource){
            const replacedFilePath = resource.createData.resource.replace(strapiCacheSrcPath,path.resolve(__dirname,'ui/pages/AuthPage/components/Login'));
            if (replacedFilePath.endsWith('.js')) {
              resource.createData.resource = replacedFilePath;
            }
          }
        }

      )
    );
  }

  return config;
};

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744649104a4585793.html

相关推荐

  • Strapi 5: Custom Login page - Stack Overflow

    I'm migrating from Strapi 4 to Strapi 5 and need to override the default login page in production.

    1天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>