How to load custom configuration on NextJS custom server
See original GitHub issueI’m trying to load my configuration to my custom server setup and this is not shown in the examples of mentioned in the documentation.
I have this file, where I load all the plugins with compose:
const withPlugins = require('next-compose-plugins')
const withEnv = require('next-env')
const withSass = require('@zeit/next-sass')
const withImages = require('next-images')
const withOptimizedImages = require('next-optimized-images')
const withSourceMaps = require('@zeit/next-source-maps')
const config = require('./config')
module.exports = withPlugins([
withEnv(config.env),
withImages(),
[withSass, config.sass],
[withOptimizedImages, config.optimizedImages],
withSourceMaps(),
], config.next)
And this is my server configuration:
const express = require('express')
const next = require('next')
const helmet = require('helmet')
const routes = require('./config').routes
const conf = require('./next.config')
const port = process.env.PORT || 3000
const dev = process.env.NODE_ENV === 'development'
const app = next({ dev, dir: './src', conf: conf() })
const handler = routes.getRequestHandler(app)
app.prepare().then(() => {
express()
.use(helmet())
.use(handler)
.listen(port, (err) => {
if (err) {
throw err
}
console.log(`> Ready on http://localhost:${port}`) // eslint-disable-line no-console
})
})
The server configuration only loads the NextJS configuration object using the conf option, but does not load the compose with plugins if I pass it.
Is there a way of using the plugins with my custom server all together?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Advanced Features: Custom Server
Start a Next.js app programmatically using a custom server. ... The custom server uses the following import to connect the server with the...
Read more >How to load custom configuration on NextJS custom server
I'm trying to load my configuration to my custom server setup and this is not shown in the examples of mentioned in the...
Read more >NextJS Custom Server - Handbook
Setup in new project ... Follow these steps to configure our custom NextJS server in your NextJS project: 1. Add a server.ts file...
Read more >Customize your Next.JS App using next.config.js ... - YouTube
In this video, we will see how we can use the next. config.js file in our Next.JS applications to take our App to...
Read more >Set Up Next.js with a Custom Express Server + Typescript
Let's go production · build:server : Build server code to dist directory · build:next : Build the Next.js application · build : Run...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Going to close this as it doesn’t follow the issue template. Questions should be asked on https://spectrum.chat/next-js.
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.