Next.js Discord

Discord Forum

Explain to me what is server.js do ?

Unanswered
Spectacled bear posted this in #help-forum
Open in Discord
Avatar
Spectacled bearOP
I see i can run npm run dev or npm start (production) for nextjs
How do i process api calls? like express server

server.js does same as express node server?

i am running node server.js it process my nextjs page but it ignore any url i type in.


const { createServer } = require('http')
const { parse } = require('url')
const next = require('next')
 
const dev = process.env.NODE_ENV !== 'production'
const hostname = 'localhost'
const port = 3000
// when using middleware `hostname` and `port` must be provided below
const app = next({ dev, hostname, port })
const handle = app.getRequestHandler()
 console.log("hello");


I put hello and expecting it to print but not happening. Who can explain?

0 Replies