You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
783 B
JavaScript

require('dotenv').config()
const express = require('express');
const next = require('next');
const port = parseInt(process.env.PORT, 10) || 3000;
const dev = process.env.NODE_ENV !== 'production';
// Configure SSR axios defaults
const axios = require('axios')
axios.defaults.baseURL = `http://localhost:${port}`
// Set up Express
const server = express();
const app = next({ dev });
const handle = app.getRequestHandler();
server.locals.dev = dev
// API Routes
server.use('/api/', require('./api/'));
// Let Next.js render pages
server.all('*', (req, res) => {
return handle(req, res);
});
// Start server
server.listen(port, err => {
if (err) throw err;
console.log(`> Ready on http://localhost:${port}`);
});
// Make sure Next.js gets its crap together
app.prepare();