nextjs - 💡(How to fix) Fix Passing configuration options as the `conf` property to the `next()` function in a custom server is ignored [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#87429Fetched 2026-04-08 02:07:01
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
issue_type_added ×1labeled ×1subscribed ×1

Error Message

  • Either respect the conf property for all settings, or update documentation to warn users of this critical limitation.

Code Example

import { createServer } from "http";
import { parse } from "url";
import next from "next";

const port = 3000;
const dev = false;
const app = next({ dev, conf: { basePath: "/config-test", devIndicators: false } });
const handle = app.getRequestHandler();

app.prepare().then(() => {
  createServer((req, res) => {
    const parsedUrl = parse(req.url!, true);
    handle(req, res, parsedUrl);
  }).listen(port);

  console.log(`> Server listening at http://localhost:${port}`);
});

---

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Enterprise
  Available memory (MB): 65144
  Available CPU cores: 20
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.12.1
Relevant Packages:
  next: 16.1.1-canary.0 // Latest available version is detected (16.1.1-canary.0).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/woodman231/next-custom1

To Reproduce

  1. Clone the examples/custom-server example from the Next.js repository.
  2. Modify the server file to the following:
import { createServer } from "http";
import { parse } from "url";
import next from "next";

const port = 3000;
const dev = false;
const app = next({ dev, conf: { basePath: "/config-test", devIndicators: false } });
const handle = app.getRequestHandler();

app.prepare().then(() => {
  createServer((req, res) => {
    const parsedUrl = parse(req.url!, true);
    handle(req, res, parsedUrl);
  }).listen(port);

  console.log(`> Server listening at http://localhost:${port}`);
});
  1. Do not include any next.config.mjs or next.config.js file.
  2. Start the server and attempt to visit http://localhost:3000/config-test.
  3. It fails with a 404 and ignores the basePath.
  4. If you now add a next.config.mjs with the same options (e.g. basePath: '/config-test', devIndicators: false), the settings are respected and it works as expected.

Current vs. Expected behavior

Expected behavior

  • Passing config options in the conf property to the next() function should have the same effect as specifying them in next.config.js/next.config.mjs.
  • Routing, basePath, devIndicators, and all other documented config settings should apply at startup, both in dev and production modes.

Actual behavior

  • The config options provided via the conf property are ignored for many settings (such as basePath).
  • Only file-based config is respected for these options.
  • This makes it impossible to control these behaviors dynamically in a custom server environment as documented.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Enterprise
  Available memory (MB): 65144
  Available CPU cores: 20
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.12.1
Relevant Packages:
  next: 16.1.1-canary.0 // Latest available version is detected (16.1.1-canary.0).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Runtime

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

Additional context

Notes

  • This happens in both development and production modes (dev: true and dev: false).
  • Bug is present in all recent versions of Next.js.
  • The issue is confirmed by source code review which appears to process the conf, but its effects do not apply for routing-level and other core settings.
  • You can easily verify this with the official custom-server example.

Impact

  • Users following the documentation have a false sense of control over config via conf.
  • There is an acute need to either fix this or to update the documentation to clarify that only file-based config works for routing/basePath and related settings.

What should happen?

  • Either respect the conf property for all settings, or update documentation to warn users of this critical limitation.

References:


extent analysis

TL;DR

  • The conf property in the next() function is ignored for certain settings like basePath, and using a next.config.mjs or next.config.js file is currently the only way to apply these settings.

Guidance

  • Verify that the issue persists by attempting to use the conf property to set basePath and other settings in a custom server environment.
  • Try using a next.config.mjs or next.config.js file to apply the desired settings, as this is currently the supported method.
  • Review the Next.js documentation and source code to understand the intended behavior of the conf property and potential workarounds.
  • Consider updating the documentation to reflect the current limitations of the conf property.

Example

  • No code snippet is provided, as the issue is related to the behavior of the next() function and its conf property, rather than a specific code example.

Notes

  • The issue appears to be a limitation of the current implementation of Next.js, and may require changes to the documentation or the underlying code to resolve.
  • The problem is not specific to a particular version of Next.js, as it has been confirmed to occur in multiple recent versions.

Recommendation

  • Apply workaround: Use a next.config.mjs or next.config.js file to apply the desired settings, as this is currently the supported method. This approach allows users to control the behavior of their Next.js application, even if the conf property is not fully supported.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

  • Passing config options in the conf property to the next() function should have the same effect as specifying them in next.config.js/next.config.mjs.
  • Routing, basePath, devIndicators, and all other documented config settings should apply at startup, both in dev and production modes.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix Passing configuration options as the `conf` property to the `next()` function in a custom server is ignored [1 participants]