首页 > 解决方案 > Nex.js 静态文件使用扩展名服务,无需下载

问题描述

我需要提供stellar.toml文件,domain/.well-known/stellar.toml并且内容类型需要是text/plain. 我尝试像这样添加下一个配置,它只有在没有扩展名的情况下保存恒星文件时才有效。

我需要在domain/.well-known/stellar.toml不提供内容domain/.well-known/stellar

module.exports = {
  async headers() {
    return [
      {
        source: "/.well-known/stellar",
        headers: [
          {
            key: "Content-Type",
            value: "text/plain",
          },
        ],
      },
    ];
  },
};

标签: javascriptreactjsstaticnext.jsserve

解决方案


您可能应该在 NextJs 的 webpack 配置中添加 toml 扩展。https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config


推荐阅读