Next.js Discord

Discord Forum

API routes not visible, probably due to next.config

Unanswered
cantoraman1 posted this in #help-forum
Open in Discord
Hey, I am using the Nextjs with pages directory. I had to enable custom webpack for the first time, and I believe my configuration messed up my API routes.

I have the following next.config.js file. If anyone has any idea if this may actually be causing my error, a help would be highly appreciated.

/** @type {import('next').NextConfig} */
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");

module.exports = {
  reactStrictMode: true,
  //distDir: 'build',
  webpack: (config, { isServer }) => {
    config.resolve.extensions.push(".ts", ".tsx");
    config.resolve.fallback = { fs: false };

    config.plugins.push(
      new NodePolyfillPlugin(),
      new CopyPlugin({
        patterns: [
          {
            from: "./node_modules/onnxruntime-web/dist/ort-wasm.wasm",
            to: "static/chunks/pages",
          },
          {
            from: "./node_modules/onnxruntime-web/dist/ort-wasm-simd.wasm",
            to: "static/chunks/pages",
          },
          {
            from: "./model",
            to: "static/chunks/pages",
          },
          {
            from: "data",
            to: "static/chunks/pages",
          },
        ],
      })
    );

    return config;
  },
};

0 Replies