Andrew-dev1.1 / server.js
truegleai
fix: handle all HTTP methods in express server to allow POST to API routes
9ea2467
raw
history blame
597 Bytes
const express = require('express');
const next = require('next');
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
const port = process.env.PORT || 3001;
app.prepare().then(() => {
const server = express();
// Handle ALL routes and methods (GET, POST, etc.)
server.all('*', (req, res) => {
return handle(req, res);
});
server.listen(port, (err) => {
if (err) throw err;
console.log(`> Open-View Ready on http://localhost:${port}`);
console.log(`> Access via: http://localhost:${port}`);
});
});