Example with micro as custom server
See original GitHub issueI am trying to combine three awesome Zeit projects (next.js + micro + now). While putting next on top of micro I keep getting errors. Did anyone make it work?
This is my example code
const next = require('next')
const { parse } = require('url')
const dispatch = require('micro-route/dispatch')
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
const defaultRoute = async function (req, res) {
return { say: 'Hello' }
}
module.exports = dispatch()
.dispatch('/api', '*', defaultRoute )
.otherwise((req, res) => {
const parsedUrl = parse(req.url, true)
handle(req, res, parsedUrl)
})
Error after running npm start
and requesting http://localhost:3000/
TypeError: Cannot read property 'hasErrors' of null
at HotReloader.getCompilationErrors (/projects/node_modules/next/dist/server/hot-reloader.js:525:23)
at Server.getCompilationError (/projects/node_modules/next/dist/server/index.js:1012:37)
at Server._callee16$ (/projects/node_modules/next/dist/server/index.js:742:39)
at tryCatch (/projects/node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (/projects/node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (/projects/node_modules/regenerator-runtime/runtime.js:117:21)
at step (/projects/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /projects/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
at F (/projects/node_modules/core-js/library/modules/_export.js:35:28)
at Server.<anonymous> (/projects/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
at Server.renderToHTML (/projects/node_modules/next/dist/server/index.js:786:23)
at Server._callee15$ (/projects/node_modules/next/dist/server/index.js:708:29)
at tryCatch (/projects/node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (/projects/node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (/projects/node_modules/regenerator-runtime/runtime.js:117:21)
at step (/projects/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Micro Frontends - extending the microservice idea to frontend ...
Extending the microservice idea to frontend development. Techniques, strategies and recipes for building a modern web app with multiple teams that can ship ......
Read more >Building a Micro-frontend Framework - Toptal
Micro -frontend architectures decompose a front-end app into semi-independent "microapps" working loosely together, making large projects more manageable.
Read more >Micro Frontends - Martin Fowler
Figure 6: Each of these servers can be built and deployed to independently. This example shows how micro frontends is not necessarily a...
Read more >5 Ways to Deploy Microservices - Semaphore CI
From VMs to Kubernetes and Serverless, there are many ways of to deploy microservices. The perfect method is determined by size and scaling ......
Read more >aol/micro-server: Microserver is a Java 8 native, zero ... - GitHub
Microserver is a Java 8 native, zero configuration, standards based, battle hardened library to run Java Rest Microservices via a standard Java main...
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
Are you running
app.prepare()
? I don’t see it in your code. Check -> https://github.com/zeit/next.js/blob/master/examples/custom-server/server.js#L9-L10Nice one, thanks 😃