1

我有一个 Next.js 应用程序,我必须将它迁移到 Digital Ocean 上的新服务器,该服务器现在是专用 cpu,突然间我的字体被用作 Content-Type: text/html; charset=utf-8 并且我收到 500 错误。这以前在另一台服务器上工作,没有更改代码库。我已经尝试了很多东西,但我被难住了。

在此处输入图像描述

const path = require("path");
const glob = require("glob");

module.exports = {
  webpack: (config, { dev }) => {
    config.module.rules.push(
      {
        test: /\.(css|scss)/,
        loader: "emit-file-loader",
        options: {
          name: "dist/[path][name].[ext]",
        },
      },
      {
        test: /\.css$/,
        use: ["babel-loader", "raw-loader", "postcss-loader"],
      },
      {
        test: /\.s(a|c)ss$/,
        use: [
          "babel-loader",
          "raw-loader",
          "postcss-loader",
          {
            loader: "sass-loader",
            options: {
              sassOptions: {
                includePaths: ["styles", "node_modules"]
                  .map((d) => path.join(__dirname, d))
                  .map((g) => glob.sync(g))
                  .reduce((a, c) => a.concat(c), []),
              },
            },
          },
        ],
      }
    );
    return config;
  },
};

编辑:我添加了我的 next.config.js 的样子

4

1 回答 1

0

原来是CORS问题。我必须通过 Express.js 更新我的 CORS 策略以允许远程服务器。这为我解决了这个问题。

于 2020-07-17T00:01:47.703 回答