如何修复错误 400 图像不显示 Next App firebase ssr

How to fix Error 400 Image not displaying Next App firebase ssr

我还在 firebase 上部署我的 ssr 应用程序。差不多好了。我只有我的图像有问题。我在控制台上收到 400 错误消息。图片来自外部url。获取的数据是正确的,但它确实以某种方式显示。你会在下面看到我的 server.js 文件和 next.config.js.

有人可以告诉我缺少什么吗?

server.js

const { https } = require('firebase-functions');
const { default: next } = require('next');

const isDev = process.env.NODE_ENV !== 'production';

const server = next({
    dev: isDev,
    //location of .next generated after running -> yarn build
    conf: { distDir: '.next' },
    image :{ domain :['assets.coingecko.com'],}
});

const nextjsHandle = server.getRequestHandler();
exports.nextServer = https.onRequest((req, res) => {
    return server.prepare()
        .then(() => {
            return nextjsHandle(req, res)
        });
});


next.config.js

const webpack = require('webpack');
const path = require('path');
//const withPlugins = require('next-compose-plugins');
//const optimizedImages = require('next-optimized-images');



module.exports = {
  images: {
    domains: ['assets.coingecko.com'],
    loader: 'imgix',
    path: 'https://assets.coingecko.com/',
  },
  reactStrictMode: true,
  entry: './src/index.js',
  sassOptions: {
    includePaths: [path.join(__dirname, 'styles')],
  },
  module: {
    rules: [
      //...
      {
        test: /\.(png|jp(e*)g|svg|gif)$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: 'images/[hash]-[name].[ext]',
            },
          },
        ],
      },
    ],
  },

  //...
}


首先我想感谢你的帮助@juliomalves。我找到了我的问题的答案。我已经在这里详细回答了问题 [1][ 如果有人遇到同样的情况。

再次感谢