From 7ed6ad01e3581da4b7de7403e77d251a98ada829 Mon Sep 17 00:00:00 2001 From: Alexander Chabin Date: Sun, 3 Dec 2023 22:52:43 +0500 Subject: [PATCH] Run server with `next dev` --- client/package.json | 2 +- client/server.js | 37 ------------------------------------- 2 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 client/server.js diff --git a/client/package.json b/client/package.json index f569b17b..cc38b5ad 100644 --- a/client/package.json +++ b/client/package.json @@ -2,7 +2,7 @@ "name": "transport-client", "version": "1.0.0", "scripts": { - "dev": "node server.js", + "dev": "next dev", "build": "next build", "lint": "next lint", "check-types": "tsc --noEmit" diff --git a/client/server.js b/client/server.js deleted file mode 100644 index 55b93f2d..00000000 --- a/client/server.js +++ /dev/null @@ -1,37 +0,0 @@ -const express = require('express'); -const next = require('next'); -const { createProxyMiddleware } = require('http-proxy-middleware'); - -const port = process.env.PORT || 3000; -const dev = process.env.NODE_ENV !== 'production'; -const app = next({ dev }); -const handle = app.getRequestHandler(); - -const apiPaths = { - '/api': { - target: 'http://localhost:3080', - pathRewrite: { - '^/api': '/api', - }, - changeOrigin: true, - }, -}; - -app.prepare() - .then(() => { - const server = express(); - - server.use('/api', createProxyMiddleware(apiPaths['/api'])); - - server.all('/*', (req, res) => { - return handle(req, res); - }); - - server.listen(port, (err) => { - if (err) throw err; - console.log(`> Ready on http://localhost:${port}`); - }); - }) - .catch((err) => { - console.log('Error:::::', err); - });