Skip to content

生产环境要如何启动bff呢? #3538

Answered by yimingjfe
baranwang asked this question in Q&A
Discussion options

You must be logged in to vote

@baranwang 目前可以通过增加一个 bootstrap 文件去启动 server,一个可参考的示例如下:

const path = require("path");
const server = require("@modern-js/prod-server").default;
const pluginBFF = require("@modern-js/plugin-bff/server").default;
const pluginKoa = require("@modern-js/plugin-koa/server").default;

async function bootstrap() {
  const config = {
    output: {
      path: ".",
    },
    bff: {
      prefix: "/api",
    },
  };

  try {
    const app = await server({
      config,
      pwd: __dirname,
      serverConfigFile: "modern.server-runtime.config",
      plugins: [pluginBFF(), pluginKoa()],
      appContext: {
        sharedDirectory: path.join(__dirname, "shared"),
        apiDirectory: path.join(__…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by chenjiahan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants