Next.js Discord

Discord Forum

Static file error

Unanswered
Cattle Egret posted this in #help-forum
Open in Discord
Cattle EgretOP
I am using nextjs with express.js and i am having problem about nextjs not being able to get the static file

 ○ Compiling / ...
 ✓ Compiled / in 6.8s (757 modules)
 GET / 200 in 7055ms
 ○ Compiling /_not-found ...
 ✓ Compiled /_not-found in 562ms (743 modules)
 GET /logo.gif 404 in 672ms
 ⨯ The requested resource isn't a valid image for /logo.gif received text/html; charset=utf-8


The initialization code:

  const express = require("express");
const next = require("next");
const config = require("../config");
const path = require("path");

module.exports = async (client) => {
  const dev = process.env.NODE_ENV !== "production";

  const app = next({ dev, dir: path.join(__dirname, "src") });

  const handler = app.getRequestHandler();

  await app.prepare();

  const server = express();

  server.all("*", (req, res) => {
    return handler(req, res);
  });

  server.listen(config.DASHBOARD.port, (err) => {
    if (err) throw err;
    console.log("Dashboard is running on port " + config.DASHBOARD.port);
  });
};

0 Replies